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
+11 -2
View File
@@ -1,10 +1,12 @@
using PostFundManagement.Domain.Abstractions;
using static PostFundManagement.Domain.Extensions.Constants;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<BudgetConfiguration, Budget>]
public class Budget : Models.Budget
public class Budget : Models.Budget, ITenantEntity
{
public virtual Tenant? Tenant { get; set; }
public virtual Project? Project { get; set; }
public virtual User? Creator { get; set; }
@@ -19,6 +21,7 @@ public sealed class BudgetConfiguration : IEntityTypeConfiguration<Budget>
builder.ToTable(nameof(Budget).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.TenantId).IsRequired();
builder.Property(f => f.ProjectId).IsRequired();
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.ApprovedBy).IsRequired(false);
@@ -27,6 +30,12 @@ public sealed class BudgetConfiguration : IEntityTypeConfiguration<Budget>
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Amount).IsRequired().HasPrecision(18, 2);
builder.HasOne(f => f.Tenant)
.WithMany()
.HasForeignKey(fk => fk.TenantId)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Project)
.WithMany()
.HasForeignKey(fk => fk.ProjectId)