19 lines
729 B
C#
19 lines
729 B
C#
using AccountManagement.Domain.TaskMediaAgg;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
namespace AccountMangement.Infrastructure.EFCore.Mappings;
|
|
|
|
public class TasksMediaMapping:IEntityTypeConfiguration<TaskMedia>
|
|
{
|
|
public void Configure(EntityTypeBuilder<TaskMedia> builder)
|
|
{
|
|
builder.ToTable("TasksMedias");
|
|
builder.HasKey(x => new { x.MediaId, x.TaskId });
|
|
|
|
builder.HasOne(x => x.Media).WithMany(x => x.TaskMedias)
|
|
.HasForeignKey(x => x.MediaId).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasOne(x => x.Tasks).WithMany(x => x.TaskMedias)
|
|
.HasForeignKey(x => x.TaskId).OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
} |