22 lines
725 B
C#
22 lines
725 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using Tiku.Domain.Common;
|
|
using Tiku.Domain.Tenancy;
|
|
|
|
namespace Tiku.Infrastructure.Persistence.Configurations;
|
|
|
|
internal static class ContentV2ConfigurationSupport
|
|
{
|
|
internal static void ConfigureTenantOwned<TEntity>(
|
|
this EntityTypeBuilder<TEntity> builder,
|
|
string tableName)
|
|
where TEntity : Entity, ITenantOwned
|
|
{
|
|
builder.ConfigureEntity(tableName);
|
|
builder.HasAlternateKey(nameof(ITenantOwned.TenantId), nameof(Entity.Id));
|
|
builder.HasOne<Tenant>().WithMany()
|
|
.HasForeignKey(nameof(ITenantOwned.TenantId))
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|