I tried to add ASP.NET identity to my existing MVC 5 project. I applied some articles about this issue.
I followed this articles: Adding ASP.NET MVC5 Identity Authentication to an existing project http://www.yagizhanpala.com/asp_net_identity_ile_mvc_projede_uyelik_islemleri/
But after the implementation, I had same problem.
my.Models.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType.
my.Models.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType.
IdentityUserLogins: EntityType: EntitySet 'IdentityUserLogins' is based on type 'IdentityUserLogin' that has no keys defined.
IdentityUserRoles: EntityType: EntitySet 'IdentityUserRoles' is based on type 'IdentityUserRole' that has no keys defined.
Note:I am using reverse code engineer to create model class.
public class ApplicationRole : IdentityRole
{
public string Description { get; set; }
public ApplicationRole() { }
public ApplicationRole(string roleName, string description) : base(roleName)
{
this.Description = description;
}
}
public class ApplicationUser : IdentityUser
{
public string Name { get; set; }
public string Surname { get; set; }
}
OnModelcreating() method includes:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new LoginMap());
modelBuilder.Configurations.Add(new RegisterMap());
}