using GameDatabase.Entities; using Microsoft.EntityFrameworkCore; using SharedProject.Enums; namespace GameDatabase.Context; public partial class TaikoDbContext { public virtual DbSet DanScoreData { get; set; } = null!; public virtual DbSet DanStageScoreData { get; set; } = null!; public virtual DbSet AiScoreData { get; set; } = null!; public virtual DbSet AiSectionScoreData { get; set; } = null!; partial void OnModelCreatingPartial(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => new { e.Baid, e.DanId }); entity.HasOne(d => d.Ba) .WithMany() .HasPrincipalKey(p => p.Baid) .HasForeignKey(d => d.Baid) .OnDelete(DeleteBehavior.Cascade); entity.Property(e => e.ClearState).HasConversion().HasDefaultValue(DanClearState.NotClear); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.Baid, e.DanId, e.SongNumber }); entity.HasOne(d => d.Parent) .WithMany(p => p.DanStageScoreData) .HasPrincipalKey(p => new { p.Baid, p.DanId }) .HasForeignKey(d => new { d.Baid, d.DanId }) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.Baid, e.SongId, e.Difficulty }); entity.HasOne(d => d.Ba) .WithMany() .HasPrincipalKey(p => p.Baid) .HasForeignKey(d => d.Baid) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.Baid, e.SongId, e.Difficulty, e.SectionIndex }); entity.HasOne(d => d.Parent) .WithMany(p => p.AiSectionScoreData) .HasPrincipalKey(p => new { p.Baid, p.SongId, p.Difficulty }) .HasForeignKey(d => new { d.Baid, d.SongId, d.Difficulty }) .OnDelete(DeleteBehavior.Cascade); }); } }