entity-framework-6

IdentityStoreManager could not be found after upgrading Microsoft.AspNet.Identity to rc1

蓝咒 提交于 2019-12-10 02:31:57
问题 After Upgrading Microsoft.AspNet.Identity.Core to 1.0.0-rc1 several errors appear in the AccountController.cs And AppModel.cs classes which are generated by the default MVC5 templates in Visual Studio 2013. Are there any release notes to explain how to resolve the breaking changes? 回答1: Update the following nuget packages: Microsoft ASP.NET Identity EntityFramework version="1.0.0-rc1" Microsoft.Owin.Security version="2.0.0-rc1" Microsoft.Owin.Security.OAuth version="2.0.0-rc1" Get these:

Exceptions when rolling back a transaction - connection already closed?

▼魔方 西西 提交于 2019-12-10 02:02:10
问题 Using Entity Framework 6.0.0, I'm seeing an exception when closing a transaction. We'd been having problems with concurrent changes to the table, so I wrapped it in a transaction, and now I'm getting exceptions on rollback. The code: public LockInfo getSharedLock(string jobid) { using (var myDbContext = new MyDbContext()) { using (var transaction = myDbContext.Database.BeginTransaction()) { try { this.logger.log("Attempting to get shared lock for {0}", jobid); var mylocks = myDbContext

How to retrieve Entity Configuration from Fluent Api

人走茶凉 提交于 2019-12-10 02:00:27
问题 Using Entity-Framework 6 I'm able to set up the configuration through Fluent Api like this: public class ApplicationUserConfiguration : EntityTypeConfiguration<ApplicationUser> { public ApplicationUserConfiguration() { this.HasKey(d => d.Id); this.Ignore(d => d.UserId); } } Source from this question Using the attribute approach I'm able to know what's the property roles by reflection, but I wonder how can I retrieve these configurations, like Key for example, with Fluent Api approach? There's

Entity Framework 6: Adding child object to parent's list vs. setting child's navigation property to parent

╄→尐↘猪︶ㄣ 提交于 2019-12-10 01:52:30
问题 I have an existing database with two tables MailServers and MailDomains in it. MailDomains has the foreign key column MailServerId pointing to the Id primary key column in MailServers . So we have a one-to-many-relationship here. I followed this article and created my Entity Framework POCOs via the "Code first from database" model in the Entity Data Model Wizard. This produced the following two C# classes: public partial class MailServer { public MailServer() { MailDomains = new HashSet

How can I use EF6 to update a many to many table

给你一囗甜甜゛ 提交于 2019-12-10 01:52:28
问题 I have two classes: public partial class ObjectiveDetail { public ObjectiveDetail() { this.SubTopics = new List<SubTopic>(); } public int ObjectiveDetailId { get; set; } public int Number { get; set; } public string Text { get; set; } public virtual ICollection<SubTopic> SubTopics { get; set; } } public partial class SubTopic { public int SubTopicId { get; set; } public string Name { get; set; } } I have an ObjectiveDetail object from the user: var web = { "objectiveDetailId":1, "number":1,

Entity Framework proper way to replace collection in one to many

拟墨画扇 提交于 2019-12-10 01:47:40
问题 Suppose a customer has many phone numbers and a phone number has only one customer. public class PhoneNumber : IValueObject { public string Number {get; set;} public string Type {get; set;} } public class Customer : IEntity { public ICollection<PhoneNumber> phones {get; private set;} //ew at no encapsulated collection support public void SetPhones(params PhoneNumber[] phones) { this.phones.Clear(); this.phones.AddRange(phones); } } If I do an EF mapping like this and run it, every time I set

Changing primary key data type in Production DB

▼魔方 西西 提交于 2019-12-09 23:43:24
问题 I am using EF code-first. I need to change the datatype of primary key of one table in our production database. public class Course { [Key] public Guid Id {get; set;} //This needs to be changed to int public string Name {get;set;} public virtual ICollection<Group> Groups {get;set;} } public class Group { [Key] public Guid Id {get; set;} public string Name {get;set;} public virtual ICollection<Course> Courses{get;set;} } As the above is a Many-Many relationship, EF has created a join table

After upgrade to EF6 - The property cannot be configured as a navigation property

牧云@^-^@ 提交于 2019-12-09 19:25:55
问题 I have a following class: [Table("TagSource")] public class TagSource { public TagSource() { this.DataSources = new HashSet<DataSource>(); } [Key] public int TagSourceId { get; set; } ... public bool IsHistorical { get; set; } public Nullable<int> ModifiedEntryId { get; set; } ... public int? AttachedTagSourceId { get; set; } [ForeignKey("AttachedTagSourceId"), InverseProperty("TagSourceId")] public virtual TagSource AttachedTagSource { get; set; } [ForeignKey("ModifiedEntryId"),

Table 'DBNAME.dbo.TableNAME' doesn't exist Entity Framework 6 with MySQL

半腔热情 提交于 2019-12-09 19:08:11
问题 I am using Entity Framework 6.0.0 with MySql Server 5.6.17 I have added MySql.Data.Entities through nuget and it installed Entity Framework 6.0.0 and MySql.Data 6.8.4 Everything was setup perfectly and working fine with some of my Business Entities. it have automigration enabled(true). Later i have added some more entities and then it started giving error like Table 'DBNAME.dbo.TABLENAME' doesn't exist Entity Framework 6 I have tried deleting whole database and recreate it again, but it didn

EF6, refreshing large DB-first entity model taking forever in VS 2015 on Windows 10, compared to VS 2015 on Windows 8.1

被刻印的时光 ゝ 提交于 2019-12-09 18:34:11
问题 Ever since I upgraded to Windows 10 my entity model has been nearly impossible to update. It takes forever to open the model designer, then forever to right click the designer to bring up the context menu to select "Update model from database". Opening the same model in VS 2015 but on Windows 8.1 is much, much faster. It doesn't seem to be just my machine since the same is happening for our other developers on Windows 10. But those on Windows 8.1 have no problems. 回答1: I had exactly the same