User in Entity type MVC5 EF6
I had the same problem and I found that I had not called
base.OnModelCreating(modelBuilder);
in my DbModel
The following method, OnModelCreating
, will create a working context. Not sure if it is the mapping you want though.
protected override void OnModelCreating(DbModelBuilder modelBuilder){ base.OnModelCreating(modelBuilder); modelBuilder.Entity<Content>() .HasMany(c => c.Editors) .WithOptional() .WillCascadeOnDelete(false); modelBuilder.Entity<Content>() .HasRequired(c => c.Owner) .WithOptional() .WillCascadeOnDelete(false); modelBuilder.Entity<IdentityUserLogin>().HasKey<string>(l => l.UserId); modelBuilder.Entity<IdentityRole>().HasKey<string>(r => r.Id); modelBuilder.Entity<IdentityUserRole>().HasKey(r => new { r.RoleId, r.UserId });}