New Scanner + People Pages (#3286)

Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo 2024-10-23 15:11:18 -07:00 committed by GitHub
parent 1ed0eae22d
commit ba20ad4ecc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
142 changed files with 17529 additions and 3038 deletions

View file

@ -66,6 +66,8 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
public DbSet<ManualMigrationHistory> ManualMigrationHistory { get; set; } = null!;
public DbSet<SeriesBlacklist> SeriesBlacklist { get; set; } = null!;
public DbSet<AppUserCollection> AppUserCollection { get; set; } = null!;
public DbSet<ChapterPeople> ChapterPeople { get; set; } = null!;
public DbSet<SeriesMetadataPeople> SeriesMetadataPeople { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder builder)
@ -155,6 +157,36 @@ public sealed class DataContext : IdentityDbContext<AppUser, AppRole, int,
builder.Entity<AppUserCollection>()
.Property(b => b.AgeRating)
.HasDefaultValue(AgeRating.Unknown);
// Configure the many-to-many relationship for Movie and Person
builder.Entity<ChapterPeople>()
.HasKey(cp => new { cp.ChapterId, cp.PersonId, cp.Role });
builder.Entity<ChapterPeople>()
.HasOne(cp => cp.Chapter)
.WithMany(c => c.People)
.HasForeignKey(cp => cp.ChapterId);
builder.Entity<ChapterPeople>()
.HasOne(cp => cp.Person)
.WithMany(p => p.ChapterPeople)
.HasForeignKey(cp => cp.PersonId)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<SeriesMetadataPeople>()
.HasKey(smp => new { smp.SeriesMetadataId, smp.PersonId, smp.Role });
builder.Entity<SeriesMetadataPeople>()
.HasOne(smp => smp.SeriesMetadata)
.WithMany(sm => sm.People)
.HasForeignKey(smp => smp.SeriesMetadataId);
builder.Entity<SeriesMetadataPeople>()
.HasOne(smp => smp.Person)
.WithMany(p => p.SeriesMetadataPeople)
.HasForeignKey(smp => smp.PersonId)
.OnDelete(DeleteBehavior.Cascade);
}
#nullable enable