Files
pfm/PostFundManagement.Domain/Configuration/Beneficiary.cs
T
hermes 109fa0602e Added entity-model mappers
Added and applied field size constants
2026-08-16 10:08:33 +02:00

40 lines
1.5 KiB
C#

using static PostFundManagement.Domain.Extensions.Constants;
namespace PostFundManagement.Domain.Configuration;
public sealed class Beneficiary : IEntityTypeConfiguration<Entities.Beneficiary>
{
public void Configure(EntityTypeBuilder<Entities.Beneficiary> builder)
{
builder.ToTable(nameof(Entities.Beneficiary).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.ProjectId).IsRequired();
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.UserId).IsRequired();
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Category).IsRequired().HasMaxLength(ShortLabelLength);
builder.Property(f => f.TargetCount).IsRequired();
builder.Property(f => f.ReachedCount).IsRequired();
builder.Property(f => f.Location).IsRequired();
builder.HasOne(f => f.Project)
.WithMany()
.HasForeignKey(fk => fk.ProjectId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.User)
.WithMany()
.HasForeignKey(fk => fk.UserId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
}
}