-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
I am having a problem I can't seem to solve (I am by no way a c# expert)
I have a abstract base entity called BaseContact
From this BaseContact I inherit PhoneContact and EmailContact.
If I try to add the Tenancy to PhoneContact and EmailContact I get the error that filters can only be added to the BaseEntity. But if I only add the Tenancy to the BaseEntity my application crashes trying to add a Phone- or a EmailContact with the message tenantId can not be null.
How do I go about adding tenancy to inherited models?
This Compiles, but crashes upon Creation of inheritated models:
modelBuilder.Entity<BaseContact>(
ctx =>
{
ctx.ToTable("Contact");
ctx.HasIndex(ct => ct.Id);
ctx.HasTenancy(() => _tenancyContext.Tenant.Id, _tenancyModelState, hasIndex: true);
ctx.HasQueryFilter(ct => ct.TenantId == _tenancyContext.Tenant.Id);
}
);
modelBuilder.Entity<PhoneContact>().HasBaseType("BaseContact");
modelBuilder.Entity<EmailContact>().HasBaseType("BaseContact");Metadata
Metadata
Assignees
Labels
No labels