Javi Zhu
Javi Zhu

Reputation: 68

How to add new columns in asp.net mvc identity with entity framework

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
   ......
}

this method can rewrite table name or column name, but how to add ?

Upvotes: 2

Views: 1621

Answers (1)

Mihail Stancescu
Mihail Stancescu

Reputation: 4138

To add new columns into the Identity tables, simply modify the classes created with the project template.

public class AppUser : IdentityUser
{
   public string UserNickName {get; set;}
}

And then add a new migration to tell EF to add the column to the AppUser which it is AspNetUsers table, if I'm not mistaken.

You can do this process with other Identity tables that you need to add column to (AppUserRole, AppUserClaim, etc...)

Upvotes: 1

Related Questions