Stable multitenancy

This commit is contained in:
2026-09-24 10:25:07 +02:00
parent ef134a5b3c
commit 8e0c099867
54 changed files with 8900 additions and 603 deletions
@@ -1,8 +1,11 @@
using PostFundManagement.Domain.Abstractions;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<DisbursementConfiguration, Disbursement>]
public class Disbursement : Models.Disbursement
public class Disbursement : Models.Disbursement, ITenantEntity
{
public virtual Tenant? Tenant { get; set; }
public virtual Project? Project { get; set; }
public virtual Milestone? Milestone { get; set; }
@@ -19,6 +22,7 @@ public sealed class DisbursementConfiguration : IEntityTypeConfiguration<Disburs
builder.ToTable(nameof(Disbursement).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.TenantId).IsRequired();
builder.Property(f => f.ProjectId).IsRequired();
builder.Property(f => f.MilestoneId).IsRequired(false);
builder.Property(f => f.CreatedBy).IsRequired();
@@ -29,6 +33,12 @@ public sealed class DisbursementConfiguration : IEntityTypeConfiguration<Disburs
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ApprovalStatus.Pending);
builder.HasOne(f => f.Tenant)
.WithMany()
.HasForeignKey(fk => fk.TenantId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Project)
.WithMany()
.HasForeignKey(fk => fk.ProjectId)