mirror of
https://github.com/TomasiDeveloping/PlayerManagement.git
synced 2026-04-16 17:22:21 +00:00
28 lines
1.4 KiB
C#
28 lines
1.4 KiB
C#
using Database.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace Database.Configurations;
|
|
|
|
public class ZombieSiegeParticipantConfiguration : IEntityTypeConfiguration<ZombieSiegeParticipant>
|
|
{
|
|
public void Configure(EntityTypeBuilder<ZombieSiegeParticipant> builder)
|
|
{
|
|
builder.HasKey(zombieSiegeParticipant => zombieSiegeParticipant.Id);
|
|
builder.Property(zombieSiegeParticipant => zombieSiegeParticipant.Id).ValueGeneratedNever();
|
|
|
|
builder.Property(zombieSiegeParticipant => zombieSiegeParticipant.PlayerId).IsRequired();
|
|
builder.Property(zombieSiegeParticipant => zombieSiegeParticipant.ZombieSiegeId).IsRequired();
|
|
builder.Property(zombieSiegeParticipant => zombieSiegeParticipant.SurvivedWaves).IsRequired();
|
|
|
|
builder.HasOne(zombieSiegeParticipant => zombieSiegeParticipant.Player)
|
|
.WithMany(player => player.ZombieSiegeParticipants)
|
|
.HasForeignKey(zombieSiegeParticipant => zombieSiegeParticipant.PlayerId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
builder.HasOne(zombieSiegeParticipant => zombieSiegeParticipant.ZombieSiege)
|
|
.WithMany(zombieSiege => zombieSiege.ZombieSiegeParticipants)
|
|
.HasForeignKey(zombieSiegeParticipant => zombieSiegeParticipant.ZombieSiegeId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
} |