Added Main
This commit is contained in:
34
noteApi/Data/ApplicationDbContext.cs
Normal file
34
noteApi/Data/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user