I'm using ASP .NET Core 2.1 for my project with IndividualAuthentication. I need extra properties for my User table so i inherited from IdentityUser
like below :
public class ApplicationUser : IdentityUser
{
[Required]
[DataType(DataType.Text)]
public string Name { get; set; }
[Required]
[DataType(DataType.Text)]
public string LastName { get; set; }
}
After this modification AspNetUsers
table is not renamed. All other identity tables are renamed. I don't know why is this happening.
After creating ApplicationUser
class i have replaced IdentityUser
with ApplicationUser
in my code of Startup.cs
Below is the code before Modification
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
After modification
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<ApplicationUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();
This is my OnModelCreating method
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
base.OnModelCreating(builder);
modelBuilder.Entity<ApplicationUser>().ToTable("User");
//modelBuilder.Entity<IdentityUser>().ToTable("User");
modelBuilder.Entity<IdentityRole>().ToTable("Role");
modelBuilder.Entity<IdentityUserClaim<string>().ToTable("UserClaim");
modelBuilder.Entity<IdentityUserRole<string>>().ToTable("UserRole");
modelBuilder.Entity<IdentityUserLogin<string>().ToTable("UserLogin");
modelBuilder.Entity<IdentityRoleClaim<string>().ToTable("RoleClaim");
modelBuilder.Entity<IdentityUserToken<string>().ToTable("UserToken");
}
Now i don't know what other thing i am missing for renaming AspNetUsers
table. I didn't find any solution and still searching.