using GameDatabase.Entities; using Microsoft.EntityFrameworkCore; namespace GameDatabase.Context; public partial class TaikoDbContext { public virtual DbSet ChallengeCompeteData { get; set; } = null; public virtual DbSet ChallengeCompeteParticipantData { get; set; } = null; public virtual DbSet ChallengeCompeteSongData { get; set; } = null; public virtual DbSet ChallengeCompeteBestData { get; set; } = null; partial void OnModelCreatingChallengeCompete(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => new { e.CompId }); entity.Property(e => e.CompeteMode).HasConversion(); entity.Property(e => e.Share).HasConversion(); entity.Property(e => e.CompeteTarget).HasConversion(); entity.Property(e => e.CreateTime).HasColumnType("datetime"); entity.Property(e => e.ExpireTime).HasColumnType("datetime"); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.CompId, e.Baid }); entity.HasOne(e => e.UserData) .WithMany() .HasPrincipalKey(p => p.Baid) .HasForeignKey(d => d.Baid) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(e => e.ChallengeCompeteData) .WithMany(p => p.Participants) .HasPrincipalKey(p => p.CompId) .HasForeignKey(d => d.CompId) .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.CompId, e.SongId }); entity.HasOne(e => e.ChallengeCompeteData) .WithMany(p => p.Songs) .HasPrincipalKey(p => p.CompId) .HasForeignKey(d => d.CompId) .OnDelete(DeleteBehavior.Cascade); entity.Property(e => e.Difficulty).HasConversion(); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.CompId, e.Baid, e.SongId }); entity.HasOne(e => e.UserData) .WithMany() .HasPrincipalKey(p => p.Baid) .HasForeignKey(d => d.Baid) .OnDelete(DeleteBehavior.Cascade); entity.HasOne(e => e.ChallengeCompeteSongData) .WithMany(p => p.BestScores) .HasPrincipalKey(p => new { p.CompId, p.SongId }) .HasForeignKey(d => new { d.CompId, d.SongId }) .OnDelete(DeleteBehavior.Cascade); entity.Property(e => e.Difficulty).HasConversion(); entity.Property(e => e.Crown).HasConversion(); entity.Property(e => e.ScoreRank).HasConversion(); }); } }