1

When registered in MVC application for the first time. It creates some default tables

AspNetRoles, 
AspNetUserClaims, 
AspNetUserLogins
AspNetUserRoles
AspNetUsers 

Where/or in which file are these default names written ?

Aravind
  • 40,391
  • 16
  • 91
  • 110

3 Answers3

1

I haven't been able to find where the default names are written in but if your goal is to ultimately change the names you can add the following code in your DBContext class like in this answer:

protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder); // This needs to go before the other rules!

        modelBuilder.Entity<ApplicationUser>().ToTable("Users");
        modelBuilder.Entity<IdentityRole>().ToTable("Roles");
        modelBuilder.Entity<IdentityUserRole>().ToTable("UserRoles");
        modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogins");
        modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaims");
    }
Community
  • 1
  • 1
Endi Zhupani
  • 736
  • 2
  • 7
  • 22
1

It is hard-coded in the IdentityDbContext class, check the source code for it and you will find it yoruself and if you want to override, you will find the same way as @Endi Zhupani indicated.

https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityDbContext.cs

Haitham Shaddad
  • 4,336
  • 2
  • 14
  • 19
0

During creating a ASP.NET MVC project, you might have seen this screen

enter image description here

When you click Change Authentication as highlighted below, it will show you this screen.

enter image description here

Based on the type of authentication, the tables are generated. If you give No Authentication. Such tables will not be seen.

The tables are created through Entity framework and code which populates the tables are in the IdentityConfig.cs in the App_Start folder.

In short, if you want Authentication you can use the existing feature of Asp.Net or modify this existing one or create a new one.

Aravind
  • 40,391
  • 16
  • 91
  • 110