I am using Asp.net MVC and I want to rename identity tables such as AspNetUsers, AspNetRoles, AspNetUserRoles To Users, UserRole, UserwithRoles Please Can any one help me ?
Asked
Active
Viewed 695 times
0
-
1Possible duplicate of [How can I change the table names when using Visual Studio 2013 ASP.NET Identity?](https://stackoverflow.com/questions/19460386/how-can-i-change-the-table-names-when-using-visual-studio-2013-asp-net-identity) – Erik Philips Dec 01 '18 at 23:40
1 Answers
0
You can give those tables a custom name of your choice in the OnModelCreating method within your ApplicationDbContext.cs file in the following way:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// custom code here...
modelBuilder.Entity<IdentityUser>().ToTable("User", "dbo");
modelBuilder.Entity<IdentityRole>().ToTable("Role", "dbo");
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole", "dbo");
modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaim", "dbo");
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin", "dbo");
modelBuilder.Entity<IdentityUserToken>().ToTable("UserToken", "dbo");
// other custom code here...
}
Darkseal
- 9,334
- 8
- 75
- 104