I\'ve been trying to create navigation properties for my collection types and I found this example of how one person accomplished it using OnModelCreating. I gave it a try i
You might have to add something like the following to OnModelCreating
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 });
See also:
I know this is a late response, and this may only work for people working off tutorials or school projects!
For me, just deleting the database, .mdf, and migrations folder fixed it. Now, I don't know if you are using migrations, but this worked for me.
I'm a novice, but what I've noticed is that Identity is very finicky with keys. Deleting the migration has helped with every (godforsaken) migration problem I've hit with my project.
I think the issue is that you have removed the calling of base
class from OnModelCreating
. Try adding that also as shown below
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
//Your configuration goes here
}