using HanyadikHetVan.Data.Entities; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace HanyadikHetVan.Data { public class ApplicationDbContext : IdentityDbContext { public DbSet Pauses { get; set; } public DbSet WeeklyTimeSpans { get; set; } public DbSet FunFacts { get; set; } public ApplicationDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasOne(s => s.WeeklyTimeSpan) .WithMany(s => s.Pauses) .OnDelete(DeleteBehavior.ClientCascade); modelBuilder.Entity() .HasOne(s => s.WeeklyTimeSpan) .WithMany(s => s.FunFacts) .OnDelete(DeleteBehavior.ClientCascade); modelBuilder.Entity() .HasOne(s => s.User) .WithMany(s => s.WeeklyTimeSpans) .OnDelete(DeleteBehavior.ClientCascade); } } }