How to rename the tables created by the EF by default?

0

Can you rename the tables created by the EF by default? When creating a project with some authentication mechanism, a number of tables corresponding to the logeo system are created automatically.

    
asked by vcasas 19.06.2018 в 03:00
source

1 answer

1

If Identity is what you mean, you can rename the tables in the same way that you would normally rename them in EF when you do not want to use the default conventions or simply by that the model should not have the same names of the entities of the applications.

protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    modelBuilder.Entity<IdentityUser>().ToTable("MisIdentidades");
    modelBuilder.Entity<ApplicationUser>().ToTable("MisUsuarios");
    modelBuilder.Entity<IdentityUserRole>().ToTable("MisRoles");
}

This is done by overwriting the onModelCreate method in the EF context as seen in this link

    
answered by 19.07.2018 / 16:35
source