35 lines
983 B
C#
35 lines
983 B
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using noteApi.Models;
|
|
|
|
namespace noteApi.Data
|
|
{
|
|
public class ApplicationDbContext : IdentityDbContext<AppUser>
|
|
{
|
|
public ApplicationDbContext(DbContextOptions dbContextOptions) : base(dbContextOptions) { }
|
|
|
|
public DbSet<Note> Notes { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder builder)
|
|
{
|
|
base.OnModelCreating(builder);
|
|
|
|
List<IdentityRole> roles = new List<IdentityRole>{
|
|
new IdentityRole
|
|
{
|
|
Name = "Admin",
|
|
NormalizedName = "ADMIN"
|
|
},
|
|
new IdentityRole
|
|
{
|
|
Name = "User",
|
|
NormalizedName = "USER"
|
|
}
|
|
};
|
|
|
|
builder.Entity<IdentityRole>().HasData(roles);
|
|
}
|
|
}
|
|
}
|