Files
blazor-saas-crm/Infrastructure/Database/MsSQL/Configuration/TenantUserConfiguration.cs
T
2026-07-21 14:14:44 +07:00

28 lines
930 B
C#

using Indotalent.Data.Entities;
using Indotalent.Shared.Consts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Indotalent.Infrastructure.Database.MsSQL.Configuration;
public class TenantUserConfiguration : IEntityTypeConfiguration<TenantUser>
{
public void Configure(EntityTypeBuilder<TenantUser> builder)
{
builder.Property(e => e.TenantId)
.HasMaxLength(GlobalConsts.StringLengthId);
builder.Property(e => e.UserId)
.HasMaxLength(GlobalConsts.StringLengthShort);
builder.Property(e => e.Summary)
.HasMaxLength(GlobalConsts.StringLengthShort);
builder.HasOne(e => e.Tenant)
.WithMany(e => e.TenantUserList)
.HasForeignKey(e => e.TenantId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasIndex(e => new { e.TenantId, e.UserId }).IsUnique();
}
}