using Microsoft.EntityFrameworkCore; using SurveyBackend.Core.Models; using SurveyLib.Core.Models; using SurveyLib.Infrastructure.EFCore.Data; namespace SurveyBackend.Infrastructure.Data; public class ApplicationDbContext : SurveyDbContext { public DbSet Users { get; set; } public DbSet Groups { get; set; } public ApplicationDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasOne() .WithMany() .HasForeignKey(s => s.CreatedBy) .OnDelete(DeleteBehavior.SetNull); modelBuilder.Entity() .HasOne() .WithMany() .HasForeignKey(c => c.CompletedBy) .OnDelete(DeleteBehavior.SetNull); } }