IdentityUserLogin<string>' requires a primary key to be defined error while adding migration

To reduce the link to a nutshell, try this:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    ...

See Above link for more.


This issue will start coming as soon as you wrote the following lines in DBContext without adding 'base.OnModelCreating(modelBuilder);'

protected override void OnModelCreating(ModelBuilder modelBuilder)
{

}

Two solutions:

1) Don't override OnModelCreating in DbContext Until it becomes necessary

2) Override but call base.OnModelCreating(modelBuilder)


The problem is AppUser is inherited from IdentityUser and their primary keys are not mapped in the method OnModelCreating of dbcontext.

There is already a post available with resolution. Visit the below link

EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType

Hope this helps.