28 lines
930 B
C#
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();
|
|
}
|
|
} |