Hello,
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?
2 Answer(s)
-
1
Hi,
OrganizationUnit already has
IMayHaveTenantinterface which hasint? TenantId. When you addedIMustHaveTenant, 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 toOrganizationUnitMarkdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
@ryancyq not sure why I never thought to do a simple association. That works quite nicely, thanks for the feedback. I ended up creating an Xyz entity with IMustHaveTenant enforced, linked to an XyzOU derived class and doing tenantId validation one save
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)