Unknown column 'Extent1.Email' in 'field list'

asp.net asp.net-identity entity-framework-6 mysql

Question

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:

enter image description here

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?

1
1
9/18/2016 2:38:12 PM

Popular Answer

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    
}
1
9/18/2016 3:11:11 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow