public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<int>, int>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
private AppRole[] CreateRoles()
{
var role1 = new AppRole
{
Id = 1,
Name = "Admin",
NormalizedName = "ADMIN"
};
var role2 = new AppRole
{
Id = 2,
Name = "User",
NormalizedName = "USER"
};
return new AppRole[] { role1, role2 };
}
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
base.OnModelCreating(builder);
builder.Entity<IdentityRole>().HasData(CreateRoles());
builder.Entity<AppUser>().HasData(CreateAppUsers());
builder.Entity<AppRole>().HasData(CreateAppUserRoles());
}
public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<int>, int>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
private AppRole[] CreateRoles()
{
var role1 = new AppRole
{
Id = 1,
Name = "Admin",
NormalizedName = "ADMIN"
};
var role2 = new AppRole
{
Id = 2,
Name = "User",
NormalizedName = "USER"
};
return new AppRole[] { role1, role2 };
}
protected override void OnModelCreating(ModelBuilder builder)
{
builder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
base.OnModelCreating(builder);
builder.Entity<IdentityRole>().HasData(CreateRoles());
builder.Entity<AppUser>().HasData(CreateAppUsers());
builder.Entity<AppRole>().HasData(CreateAppUserRoles());
}