28 lines
960 B
C#
28 lines
960 B
C#
using JSMR.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace JSMR.Infrastructure.Data.Configuration;
|
|
|
|
public sealed class VoiceWorkCreatorConfiguration : IEntityTypeConfiguration<VoiceWorkCreator>
|
|
{
|
|
public void Configure(EntityTypeBuilder<VoiceWorkCreator> builder)
|
|
{
|
|
builder.ToTable("VoiceWorkCreators");
|
|
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);
|
|
}
|
|
} |