Skip to content

Instantly share code, notes, and snippets.

@demonguru18
Created February 10, 2019 23:27
Show Gist options
  • Save demonguru18/bbf96cdba4a822f216d9ef776c40ff58 to your computer and use it in GitHub Desktop.
Save demonguru18/bbf96cdba4a822f216d9ef776c40ff58 to your computer and use it in GitHub Desktop.
Application Database Context Class
using System;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using NG_Core_Auth.Models;
namespace NG_Core_Auth.Data
{
public class ApplicationDbContext : IdentityDbContext<IdentityUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
// Creatin Roles for or application
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<IdentityRole>().HasData(
new { Id = "1", Name = "Admin", NormalizedName = "ADMIN" },
new { Id = "2", Name = "Customer", NormalizedName = "CUSTOMER" },
new { Id = "3", Name = "Moderator", NormalizedName = "MODERATOR" }
);
}
public DbSet<ProductModel> Products { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment