Michael
Michael

Reputation: 13636

Add column to created identity table in asp.net mvc project?

I use identity 2.0 in my MVC 5 project.

First time when I run the project in my DB has been created all default tables for authentication and authorization:

enter image description here

In AspNetUsers table I need to create additional column named LoyoutId of type integer.

My question is how can I add column to created default tables?

Upvotes: 2

Views: 3942

Answers (1)

Roman Marusyk
Roman Marusyk

Reputation: 24619

You can add profile data for the user by adding more properties to your ApplicationUser class, please visit this to learn more.

In your case:

public class ApplicationUser : IdentityUser
{
     public int LoyoutId { get; set; }
}

Then open the Package Manager Console and execute following commands:

PM> Enable-migrations //You don't need this as you have already done it
PM> Add-migration Give_it_a_name //This will generate a database script file
PM> Update-database //Run script file against database.

Now, all the new properties will turn into AspNetUsers table.

Upvotes: 3

Related Questions