Fix db seeding, migration, repository services

This commit is contained in:
danial23 2025-05-19 22:22:33 -04:00
parent 872dc1e263
commit 6b87902ca7
Signed by: danial23
SSH key fingerprint: SHA256:IJ8VP0j2WMUVweTYnzUUnEjNgPnGx+mAt+RhqWZ01bU
22 changed files with 606 additions and 64 deletions

View file

@ -3,7 +3,6 @@ namespace CSR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using CSR.Infrastructure.Persistence.Configurations;
public class CSRDbContext(DbContextOptions<CSRDbContext> options) : DbContext(options)
{
public DbSet<User> Users { get; set; }
@ -23,14 +22,9 @@ public class CSRDbContext(DbContextOptions<CSRDbContext> options) : DbContext(op
.WithMany(r => r.Users)
.HasForeignKey(u => u.RoleId);
// --- Seed data --- //
var adminRole = new Role { Id = 1, Name = "Admin" };
var userRole = new Role { Id = 2, Name = "User" };
modelBuilder.Entity<Role>()
.HasData(adminRole, userRole);
.HasIndex(r => r.Name)
.IsUnique();
base.OnModelCreating(modelBuilder);
}