Stable multitenancy
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
namespace PostFundManagement.Domain.Entities;
|
||||
|
||||
[EntityTypeConfiguration<TenantUserConfiguration, TenantUser>]
|
||||
public class TenantUser : Models.TenantUser
|
||||
{
|
||||
public virtual Tenant? Tenant { get; set; }
|
||||
|
||||
[ForeignKey(nameof(CreatedBy))]
|
||||
public virtual User? Creator { get; set; }
|
||||
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public virtual User? User { get; set; }
|
||||
}
|
||||
|
||||
@@ -17,6 +18,8 @@ public sealed class TenantUserConfiguration : IEntityTypeConfiguration<TenantUse
|
||||
builder.ToTable(nameof(TenantUser).Pluralize());
|
||||
|
||||
builder.HasKey(pk => pk.Id);
|
||||
builder.HasIndex(tu => new { tu.TenantId, tu.UserId }).IsUnique();
|
||||
|
||||
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||
builder.Property(f => f.CreatedBy).IsRequired();
|
||||
builder.Property(f => f.UserId).IsRequired();
|
||||
|
||||
Reference in New Issue
Block a user