2022-10-26 18:42:11 +02:00
|
|
|
|
using GameDatabase.Entities;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using SharedProject.Enums;
|
|
|
|
|
|
|
|
|
|
namespace GameDatabase.Context;
|
2022-08-28 12:41:37 +02:00
|
|
|
|
|
|
|
|
|
public partial class TaikoDbContext
|
|
|
|
|
{
|
|
|
|
|
public virtual DbSet<DanScoreDatum> DanScoreData { get; set; } = null!;
|
|
|
|
|
public virtual DbSet<DanStageScoreDatum> DanStageScoreData { get; set; } = null!;
|
2022-09-17 20:06:11 +02:00
|
|
|
|
public virtual DbSet<AiScoreDatum> AiScoreData { get; set; } = null!;
|
|
|
|
|
public virtual DbSet<AiSectionScoreDatum> AiSectionScoreData { get; set; } = null!;
|
2022-08-28 12:41:37 +02:00
|
|
|
|
|
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<DanScoreDatum>(entity =>
|
|
|
|
|
{
|
2023-10-17 12:57:56 +02:00
|
|
|
|
entity.HasKey(e => new { e.Baid, e.DanId, e.DanType });
|
2022-08-29 14:46:28 +02:00
|
|
|
|
|
2022-08-28 12:41:37 +02:00
|
|
|
|
entity.HasOne(d => d.Ba)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasPrincipalKey(p => p.Baid)
|
|
|
|
|
.HasForeignKey(d => d.Baid)
|
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
2022-08-29 14:46:28 +02:00
|
|
|
|
|
|
|
|
|
entity.Property(e => e.ClearState).HasConversion<uint>().HasDefaultValue(DanClearState.NotClear);
|
2023-10-21 08:36:23 +02:00
|
|
|
|
entity.Property(e => e.DanType).HasConversion<int>().HasDefaultValue(DanType.Normal).HasSentinel(0);
|
2022-08-28 12:41:37 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<DanStageScoreDatum>(entity =>
|
|
|
|
|
{
|
2023-10-17 12:57:56 +02:00
|
|
|
|
entity.HasKey(e => new { e.Baid, e.DanId, e.DanType, e.SongNumber });
|
2022-08-28 12:41:37 +02:00
|
|
|
|
|
|
|
|
|
entity.HasOne(d => d.Parent)
|
2022-08-29 15:03:49 +02:00
|
|
|
|
.WithMany(p => p.DanStageScoreData)
|
2023-10-17 12:57:56 +02:00
|
|
|
|
.HasForeignKey(d => new { d.Baid, d.DanId, d.DanType })
|
2022-08-28 12:41:37 +02:00
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
2023-10-21 08:36:23 +02:00
|
|
|
|
entity.Property(e => e.DanType).HasConversion<int>().HasDefaultValue(DanType.Normal).HasSentinel(0);
|
2022-08-28 12:41:37 +02:00
|
|
|
|
});
|
2022-09-17 20:06:11 +02:00
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<AiScoreDatum>(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);
|
|
|
|
|
});
|
2022-10-26 18:42:41 +02:00
|
|
|
|
|
|
|
|
|
|
2022-09-17 20:06:11 +02:00
|
|
|
|
modelBuilder.Entity<AiSectionScoreDatum>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasKey(e => new { e.Baid, e.SongId, e.Difficulty, e.SectionIndex });
|
|
|
|
|
|
|
|
|
|
entity.HasOne(d => d.Parent)
|
|
|
|
|
.WithMany(p => p.AiSectionScoreData)
|
2022-10-26 18:42:41 +02:00
|
|
|
|
.HasPrincipalKey(p => new { p.Baid, p.SongId, p.Difficulty })
|
|
|
|
|
.HasForeignKey(d => new { d.Baid, d.SongId, d.Difficulty })
|
2022-09-17 20:06:11 +02:00
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
});
|
2022-08-28 12:41:37 +02:00
|
|
|
|
}
|
|
|
|
|
}
|