PlayerManagement/Database/Configurations/ZombieSiegeConfiguration.cs
2024-11-28 13:16:41 +01:00

26 lines
1.2 KiB
C#

using Database.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Database.Configurations;
public class ZombieSiegeConfiguration : IEntityTypeConfiguration<ZombieSiege>
{
public void Configure(EntityTypeBuilder<ZombieSiege> builder)
{
builder.HasKey(zombieSiege => zombieSiege.Id);
builder.Property(zombieSiege => zombieSiege.Id).ValueGeneratedNever();
builder.Property(zombieSiege => zombieSiege.EventDate).IsRequired();
builder.Property(zombieSiege => zombieSiege.AllianceSize).IsRequired();
builder.Property(zombieSiege => zombieSiege.CreatedBy).IsRequired().HasMaxLength(150);
builder.Property(zombieSiege => zombieSiege.Level).IsRequired();
builder.Property(zombieSiege => zombieSiege.ModifiedOn).IsRequired(false);
builder.Property(zombieSiege => zombieSiege.ModifiedBy).IsRequired(false).HasMaxLength(150);
builder.HasOne(zombieSiege => zombieSiege.Alliance)
.WithMany(alliance => alliance.ZombieSieges)
.HasForeignKey(zombieSiege => zombieSiege.AllianceId)
.OnDelete(DeleteBehavior.Cascade);
}
}