Reputation: 9644
I'm trying to customize IdentityUser
with a couple of extra fields
public class User : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
And changing the name of the table
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUser>().ToTable("Auth_Users", "web");
modelBuilder.Entity<User>().ToTable("Auth_Users", "web");
}
Pretty straightforward, it works, I have my table web.Auth_Users
. The bad thing is that the other tables containing user id, so AspNetUsersClaim
, AspNetUserLogins
and AspNetUsersRole
, add a column named IdentityUser_Id
that is always set to NULL
Why? Where does it come from and how can I avoid it to be created?
Upvotes: 1
Views: 606
Reputation: 23200
You are getting this weird column because of this line modelBuilder.Entity<IdentityUser>().ToTable("Auth_Users", "web");
Just remove it. Finally you must have this code :
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>().ToTable("Auth_Users", "web");
}
Upvotes: 2