You must Sign In to post a response.
  • Category: ASP.NET

    Custom Table names asp.net identity in MVC5

    all the table created in Asp.net identity starts with AspNet

    e.g AspNetUsers,

    I dont want to follow this, i want Identity create User_TB table for me istead, how can I achieve this?
  • #765197
    Hi,
    Try this:
    //1st. Override OnModelCreating event
    protected override void OnModelCreating(System.Data.Entity.DbModelBuilder myModelBuilder)
    {
    //2nd. Add this
    base.OnModelCreating(myModelBuilder);
    myModelBuilder.Entity<IdentityUser>().ToTable("User_TBUsers");
    myModelBuilder.Entity<User>().ToTable("User_TBUsers");
    myModelBuilder.Entity<ApplicationUser>().ToTable("User_TBUsers").
    }

    Hope it helps.
    Regards,
    Shashikant Gurav
    shashikantgurav22@gmail.com


Sign In to post your comments