using Foxel.Models.DataBase; using Microsoft.EntityFrameworkCore; namespace Foxel; public class MyDbContext(DbContextOptions options) : DbContext(options) { public DbSet Pictures { get; set; } = null!; public DbSet Users { get; set; } = null!; public DbSet Tags { get; set; } = null!; public DbSet Configs { get; set; } = null!; public DbSet Favorites { get; set; } = null!; public DbSet Albums { get; set; } = null!; public DbSet Roles { get; set; } = null!; public DbSet Logs { get; set; } = null!; public DbSet BackgroundTasks { get; set; } = null!; public DbSet StorageModes { get; set; } = null!; public DbSet Faces { get; set; } = null!; public DbSet FaceClusters { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasOne(a => a.CoverPicture) .WithMany() .HasForeignKey(a => a.CoverPictureId) .OnDelete(DeleteBehavior.SetNull); modelBuilder.Entity() .HasMany(a => a.Pictures) .WithOne(p => p.Album) .HasForeignKey(p => p.AlbumId) .OnDelete(DeleteBehavior.Cascade); } }