Added configurations for entity builders. Also added VoiceWorkLocaalization entity.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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("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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user