SteinTech
SteinTech

Reputation: 4068

how to customize the table name for the AspNetUsers table

I'm implementing Identity and wants to customize the table names. I have successfully customized all tables except "AspNetUsers".

Code:

builder.Entity<UserProfile>(opt => opt.ToTable("IdentityUserProfile"));
builder.Entity<User>(opt => opt.ToTable("IdentityUser"));
builder.Entity<IdentityRole<int>>(opt => opt.ToTable("IdentityRole"));
builder.Entity<IdentityUserRole<int>>(opt => opt.ToTable("IdentityUserRole"));
builder.Entity<IdentityUserClaim<int>>(opt => opt.ToTable("IdentityUserClaim"));
builder.Entity<UserProfileLogin>(opt => opt.ToTable("IdentityUserProfileLogin"));
builder.Entity<IdentityUserToken<int>>(opt => opt.ToTable("IdentityUserToken"));
builder.Entity<IdentityRoleClaim<int>>(opt => opt.ToTable("IdentityRoleClaim"));

the type UserProfile inherits IdentityUser, so I would like to rename AspNetUsers to IdentityUserProfile

any suggestions??

Upvotes: 1

Views: 44

Answers (1)

Fraze
Fraze

Reputation: 948

You can do so similarly to how you already tried, like so:

builder.Entity<IdentityUser>(b =>
{
    b.ToTable("IdentityUserProfile");
});

This will rename the table implemented by the base type IdentityUser

Upvotes: 1

Related Questions