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
@@ -1,7 +1,34 @@
using static PostFundManagement.Domain.Extensions.Constants;
namespace PostFundManagement.Domain.Entities;
[EntityTypeConfiguration<Configuration.Entities.Organisation, Organisation>]
[EntityTypeConfiguration<OrganisationConfiguration, Organisation>]
public class Organisation : Models.Organisation
{
public virtual User? Creator { get; set; }
}
public sealed class OrganisationConfiguration : IEntityTypeConfiguration<Organisation>
{
public void Configure(EntityTypeBuilder<Organisation> builder)
{
builder.ToTable(nameof(Organisation).Pluralize());
builder.HasKey(pk => pk.Id);
builder.Property(f => f.CreatedBy).IsRequired();
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
builder.Property(f => f.RegistrationNo).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Name).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Email).IsRequired().HasMaxLength(LabelLength);
builder.Property(f => f.Type).IsRequired().HasConversion<int>().HasDefaultValueSql("5")
.HasSentinel(OrganisationType.PrivateLimitedCompany);
builder.Property(f => f.Status).IsRequired().HasConversion<int>().HasDefaultValueSql("1")
.HasSentinel(ActivityStatus.Active);
builder.HasOne(f => f.Creator)
.WithMany()
.HasForeignKey(fk => fk.CreatedBy)
.IsRequired()
.OnDelete(DeleteBehavior.NoAction);
}
}