using ErsatzTV.Core.Domain; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace ErsatzTV.Infrastructure.Data.Configurations { public class TelevisionShowConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("TelevisionShows"); builder.HasOne(show => show.Metadata) .WithOne(metadata => metadata.TelevisionShow) .HasForeignKey(metadata => metadata.TelevisionShowId) .OnDelete(DeleteBehavior.Cascade); builder.HasMany(show => show.Seasons) .WithOne(season => season.TelevisionShow); builder.HasMany(show => show.Sources) .WithOne(source => source.TelevisionShow) .HasForeignKey(source => source.TelevisionShowId) .OnDelete(DeleteBehavior.Cascade); } } }