I renamed the standard identity tables:
public class User : IdentityUser
{
//...
public string Name { get; set; }
public string Surname { get; set; }
public DateTime? RegisteredDate { get; set; }
public DateTime? LastLoginDate { get; set; }
//...
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>().ToTable("Users");
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<IdentityRole>().ToTable("Roles");
modelBuilder.Entity<Role>().ToTable("Roles");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims");
}
and got this:
What do I need to do in modelBuilder
to drop this column?
The Discriminator
column is used and required in Table-Per-Hierarchy inheritance scenarios.
Code First has to add a special column to distinguish between persistent classes. This isn’t a property of the persistent class in our object model; it’s used internally by EF Code First. By default, the column name is Discriminator
, and its type is string. The values defaults to the persistent class names —in this case, User
.
More info
Update
If you don't want that column, you can make User
part of the model not IdentityUser
for instance by adding a DbSet<User>
to your context:
modelBuilder.Entity<User>().ToTable("Users");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With