I've built out a new entity that extends the OrganizationUnit with a new field, and some additional new table as references. Everything is working smoothly, however I'd like to enforce tenantId requirements on my entity with IMustHaveTenant. The issue I'm running is when running add-migration, VS insists on trying to add tenantId to the abporganizationunits table, even though it's already there. I've tried adding [NotMapped] annotation to the tenantID in my class but that doesnt' seem to work.
Is there a way to do this that I'm missing, or should I just add checks for tenantId.HasValue in my domain service (which is what I'm doing now), before progressing with business logic?
OrganizationUnit already has
IMayHaveTenantinterface which has
int? TenantId. When you added
IMustHaveTenant, EF Core most likely treating these two properties as different columns.
I would suggest to revisit the need to enforce tenant id on the extended entity or it might be easier to create another entity with
IMustHaveTenantand link it to