Al verificar las consultas SQL generadas por EF, descubrí que el problema estaba relacionado con UserName (varchar utf8 256) en la tabla AspNetUsers y Name (varchar utf8 256) en la tabla AspNetRoles, mientras que la tabla para HistoryRow estaba bien.
Así que los siguientes códigos resolvieron el problema.
public class WebPortalDbContext : IdentityDbContext<ApplicationUser>
{
public WebPortalDbContext()
: base("IdentityConnection")
{
}
public static WebPortalDbContext Create()
{
return new WebPortalDbContext();
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Microsoft.AspNet.Identity.EntityFramework.IdentityRole>()
.Property(c => c.Name).HasMaxLength(128).IsRequired();
modelBuilder.Entity<Microsoft.AspNet.Identity.EntityFramework.IdentityUser>().ToTable("AspNetUsers")//I have to declare the table name, otherwise IdentityUser will be created
.Property(c => c.UserName).HasMaxLength(128).IsRequired();
}
}
Para aclarar la solución, aquí están las bibliotecas que estoy usando:
- EF 6.1.0
- Microsoft ASP.NET Identity EntityFramework 2.0.0
- Identidad ASP.NET Owin 2.0.0
- Bibliotecas MySql .NET 6.8.3
Y esta solución también funciona para
- EF 6.1.1
- Microsoft ASP.NET Identity EntityFramework 2.0.1
- Identidad ASP.NET Owin 2.0.1