Colocated entity type configurations with entities

Added tenant entities and models
Modified db context
This commit is contained in:
2026-09-21 09:34:49 +02:00
parent 2d0f2b494a
commit 78b03b6996
58 changed files with 1174 additions and 1012 deletions
+30 -1
View File
@@ -1,9 +1,38 @@
using static PostFundManagement.Domain.Extensions.Constants;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.Entities.Outcome, Outcome>]
[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);
}
}