Due to only having one MSSQL Database with my Webhost I like to prefix my table names to separate them.
I run multiple small sites on my host, who are great, but I can't justify £50 per MSSQL instance, so this solution works for me.
To rename the table names, inside your ApplicationDbContext class, use the following code:
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity().ToTable("Users");
modelBuilder.Entity().ToTable("UserRoles");
modelBuilder.Entity().ToTable("UserLogins");
modelBuilder.Entity().ToTable("UserClaims");
modelBuilder.Entity().ToTable("Roles");
}
Obviously, the section inside the .ToTable("") part is where you specify your bespoke name.
Tags
c# (3)
Statiq (3)
General (2)
javascript (1)
Azure (1)
Penny Pinching (1)
asp.net (1)
MSSQL (1)
Windows (1)
jQuery (1)
Share this
TweetConnect with me
Tweets by TryingToCode