I would like to rename the default identity table names:
I understand how to do this using EF6:
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>()
.ToTable("Users", "dbo").Property(p => p.Id).HasColumnName("User_Id");
modelBuilder.Entity<User>()
.ToTable("Users", "dbo").Property(p => p.Id).HasColumnName("User_Id");
}
However I'm struggling with EF7 as the DbModelBuilder has been replaced with ModelBuilder. Any suggestions?
You must use ForSqlServer or ForRelational in the SqlServerPropertyBuilder to change the column name and in the modelBuilder to change the table name
modelBuilder.Entity<IdentityUser>()
.Property(o => o.Id)
.ForSqlServer()
.Column("User_Id")
modelBuilder.Entity<IdentityUser>()
.ForSqlServer()
.Table("User")
Update : For the beta 5 is not longer mandatory to use ForSqlServer
Try
builder.Entity<ApplicationUser>().ToTable("User");
builder.Entity<ApplicationRole>().ToTable("Role");
builder.Entity<IdentityUserRole<string>>().ToTable("UserRole");
builder.Entity<IdentityUserClaim<string>>().ToTable("UserClaim");
builder.Entity<IdentityUserLogin<string>>().ToTable("UserLogin");
builder.Entity<IdentityRoleClaim<string>>().ToTable("RoleClaim");
builder.Entity<IdentityUserToken<string>>().ToTable("UserToken");
@noelbr