using JSMR.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace JSMR.Infrastructure.Data.Configuration; public sealed class VoiceWorkCreatorConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("voice_work_creators"); builder.HasKey(x => new { x.VoiceWorkId, x.CreatorId }); builder.HasOne(x => x.VoiceWork) .WithMany(v => v.VoiceWorkCreators) .HasForeignKey(x => x.VoiceWorkId) .OnDelete(DeleteBehavior.Cascade); builder.HasOne(x => x.Creator) .WithMany() .HasForeignKey(x => x.CreatorId) .OnDelete(DeleteBehavior.Cascade); builder.HasIndex(x => x.CreatorId); builder.HasIndex(x => new { x.VoiceWorkId, x.Position }); builder.HasIndex(x => x.IsValid); } }