34 lines
920 B
C#
34 lines
920 B
C#
using Koogle.Domain.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Koogle.Infrastructure.Data.Configurations;
|
|
|
|
public class GamePersonConfiguration : IEntityTypeConfiguration<GamePerson>
|
|
{
|
|
public void Configure(EntityTypeBuilder<GamePerson> builder)
|
|
{
|
|
builder.ToTable("GamePersons");
|
|
|
|
builder.HasKey(x => new { x.GameId, x.PersonId });
|
|
|
|
builder.HasOne(x => x.Game)
|
|
.WithMany(x => x.GamePersons)
|
|
.HasForeignKey(x => x.GameId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasOne(x => x.Person)
|
|
.WithMany()
|
|
.HasForeignKey(x => x.PersonId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasIndex(x => x.PersonId);
|
|
}
|
|
}
|
|
|