Created
February 10, 2019 23:27
-
-
Save demonguru18/bbf96cdba4a822f216d9ef776c40ff58 to your computer and use it in GitHub Desktop.
Application Database Context Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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