Created
May 12, 2016 20:26
-
-
Save caco0516/1325588068e44fbe3021ea547279f39d to your computer and use it in GitHub Desktop.
Change tables names of a new Web App Project in Visual Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> | |
{ | |
public ApplicationDbContext() | |
: base("DefaultConnection", throwIfV1Schema: false) | |
{ | |
} | |
public static ApplicationDbContext Create() | |
{ | |
return new ApplicationDbContext(); | |
} | |
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
{ | |
base.OnModelCreating(modelBuilder); | |
modelBuilder.Entity<ApplicationUser>().ToTable("Users"); | |
modelBuilder.Entity<IdentityUser>().ToTable("Users"); | |
modelBuilder.Entity<IdentityRole>().ToTable("Roles"); | |
modelBuilder.Entity<IdentityUserClaim>().ToTable("Claims"); | |
modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins"); | |
modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a example of how to change names of tables auto generated by VS template project . This is useful when you already have a database with this kind of data or just need database generate by this project , on other projects.
Has you can see you can change users table name from "AspNetUsers" to "Users", in example above you see all tables required by auth system , with a new name.