phronCare/phronCare.API/Models/phronCareDbContext.cs

60 lines
2.0 KiB
C#
Raw Permalink Normal View History

2025-01-24 19:17:26 -03:00
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
2025-04-29 18:52:49 -03:00
using phronCare.API.Models.Security;
2025-01-24 19:17:26 -03:00
namespace phronCare.API.Models
{
2025-04-29 18:52:49 -03:00
public class phronCareDbContext : IdentityDbContext<ApplicationUser>
2025-01-24 19:17:26 -03:00
{
2025-04-29 18:52:49 -03:00
public phronCareDbContext(DbContextOptions<phronCareDbContext> options) : base(options)
2025-01-24 19:17:26 -03:00
{
}
2025-04-29 18:52:49 -03:00
2025-01-24 19:17:26 -03:00
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
//SeedRoles(builder);
}
2025-04-29 18:52:49 -03:00
2025-01-24 19:17:26 -03:00
private static void SeedRoles(ModelBuilder modelBuilder)
{
modelBuilder.Entity<IdentityRole>().HasData
2025-04-29 18:52:49 -03:00
(
2025-01-24 19:17:26 -03:00
new IdentityRole() { Name = "Administrator", ConcurrencyStamp = DateTime.Today.ToString(), NormalizedName = "administrator" },
new IdentityRole() { Name = "User", ConcurrencyStamp = DateTime.Today.ToString(), NormalizedName = "user" }
2025-04-29 18:52:49 -03:00
);
2025-01-24 19:17:26 -03:00
}
}
}
2025-04-29 18:52:49 -03:00
//using Microsoft.AspNetCore.Identity;
//using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
//using Microsoft.EntityFrameworkCore;
//namespace phronCare.API.Models
//{
// public class phronCareDbContext: IdentityDbContext<IdentityUser>
// {
// public phronCareDbContext(DbContextOptions<phronCareDbContext> options):base(options)
// {
// }
// protected override void OnModelCreating(ModelBuilder builder)
// {
// base.OnModelCreating(builder);
// //SeedRoles(builder);
// }
// private static void SeedRoles(ModelBuilder modelBuilder)
// {
// modelBuilder.Entity<IdentityRole>().HasData
// (
// new IdentityRole() { Name = "Administrator", ConcurrencyStamp = DateTime.Today.ToString(), NormalizedName = "administrator" },
// new IdentityRole() { Name = "User", ConcurrencyStamp = DateTime.Today.ToString(), NormalizedName = "user" }
// );
// }
// }
//}