I have already created ASP.NET MVC Template and its structure look like this.
Now go to Model folder and open the IdentityModels.cs class and modify,
- using Microsoft.AspNet.Identity.EntityFramework;
- namespace Demo.Models
- {
-
- public class ApplicationUser: IdentityUser {}
- public class ApplicationDbContext: IdentityDbContext < ApplicationUser >
- {
- public ApplicationDbContext(): base("DefaultConnection") {}
-
- protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- modelBuilder.Entity < ApplicationUser > ().ToTable("tblCustomUser");
- modelBuilder.Entity < IdentityUserRole > ().ToTable("tblCustomUserRole");
- modelBuilder.Entity < IdentityUserLogin > ().ToTable("tblCustomUserLogin");
- modelBuilder.Entity < IdentityUserClaim > ().ToTable("tblCustomUserClaim");
- modelBuilder.Entity < IdentityRole > ().ToTable("tblCustomRole");
- modelBuilder.Entity < IdentityUser > ().ToTable("CustomUserLoginTable");
- }
- }
- }
Step 2: Enable Migration
Open package manager console and run following command,
- enable-migrations
- add-migration customtable
- update-database
After run above command check the database table and its look like this,
So we converted default table to new table name,
AspNetRoles -->tblCustomRole
AspNetUserClaims -->tblCustomUserClaim
AspNetUserLogins -->tblCustomUserLogin
AspNetUserRoles -->tblCustomUserRole
AspNetUser -->CustomUserLoginTable
ApplicationUser -->tblCustomUser