Files
pfm/PostFundManagement.Domain/Entities/Outcome.cs
T
hermes 78b03b6996 Colocated entity type configurations with entities
Added tenant entities and models
Modified db context
2026-09-21 09:34:49 +02:00

38 lines
1.3 KiB
C#

using static PostFundManagement.Domain.Extensions.Constants;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<OutcomeConfiguration, Outcome>]
public class Outcome : Models.Outcome
{
public virtual Beneficiary? Beneficiary { get; set; }
public virtual User? Creator { get; set; }
}
public sealed class OutcomeConfiguration : IEntityTypeConfiguration<Outcome>
{
public void Configure(EntityTypeBuilder<Outcome> builder)
{
builder.ToTable(nameof(Outcome).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.BeneficiaryId).IsRequired();
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Description).IsRequired().HasMaxLength(TextLength);
builder.HasOne(f => f.Beneficiary)
.WithMany()
.HasForeignKey(fk => fk.BeneficiaryId)
.IsRequired()
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
}
}