using static PostFundManagement.Domain.Extensions.Constants; namespace PostFundManagement.Domain.Configuration.Entities; public sealed class Beneficiary : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable(nameof(Domain.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); } }