// 1. Create a model that inherit from Microsoft.AspNetCore.Identity.IdentityUser
public class User : Microsoft.AspNetCore.Identity.IdentityUser
{
public string Nom { get; set; }
public string Prenom { get; set; }
}
// 2.Create a datacontext that inherits from typed IdentityDbContext<User>
public class DataContext : IdentityDbContext<User>
{
public DataContext(DbContextOptions options) : base(options)
{
}
}
// 3. COnfigure startup file
services.AddIdentity<User, IdentityRole>(conf =>
{
conf.User.RequireUniqueEmail = true;
conf.Password.RequiredLength = 6;
}).AddEntityFrameworkStores<DataContext>().AddDefaultTokenProviders();
// class to be injected in order to access the store
UserManager<User>, UserRole<User>
//apply migration
add-migration MyFirstMigration
Update-Database
dotnet ef migrations add MyFirstMigration
dotnet ef database update