The error in package manager console :
EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.
'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.
Code I am using:
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual ApplicationUser ApplicationUser { get; set; }
In OnmodelCreating
I have:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
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 });
}
I also checked the database, and the Identity tables have been created and have primary keys also.