I am trying to implement ASP.NET Identity with a MySql database. After encountering some difficulties, which seemed to be related to the Identity version I was using, I updated it, and now I have different errors I am dealing with.
Initially it stated that it could not find the XXX.aspnetusers table, I found I should add the below code to map it to how the table is created in the MySql database.
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("my_aspnet_users");
}
Now that fixed the error, now I am facing this issue:
Looking at the database, I can see that indeed the Email field is not created, I want to know why aren't all the IdentityUser fields added?
You have to map each and every property as shown below.
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>().ToTable("my_aspnet_users");
modelBuilder.Entity<ApplicationUser>().Property(t => t.Email).HasColumnName("Email");
//map other properties too
}