[ENH] Align Tenant.Id with Tenant.TenantId for consistency and clarity #6041
Replies: 4 comments
-
I was actually thinking that a Tenant's TenantId doesn't represent its own primary key, but the tenant it is itself a part of. In other words, a tenant can itself be part of a parent tenant. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply and great explanation about hierarchical tenants. That makes a lot of sense now. |
Beta Was this translation helpful? Give feedback.
-
Great! Good idea, let's convert this to a discussion 👍🏻 |
Beta Was this translation helpful? Give feedback.
-
What about ParentTenantId ? to avoid confusion? |
Beta Was this translation helpful? Give feedback.
-
Enhancement Request: Aligning
Tenant.Id
withTenant.TenantId
Enhancement Overview
I propose a discussion on whether we should treat
Tenant.Id
as equivalent toTenant.TenantId
.The
Tenant
class, which inherits from theEntity
class, contains aTenantId
property. In a multi-tenancy scenario, it's straightforward for core entities to have aTenantId
property. However, for theTenant
class itself, I believe thatEntity.Id
is sufficient to represent the concept ofTenantId
.Proposed Enhancement
I suggest overriding the
TenantId
property in theTenant
class as follows:Description of the enhancement
This change could improve readability and prevent potential misuse of the
Tenant
class. It ensures conceptual consistency, as a Tenant'sTenantId
is logically identical to itsId
. Additionally, it avoids redundancy by preventing the need to manage two identical values.Impact of Enhancement
The proposed solution would eliminate the flexibility to set a Tenant's
TenantId
andId
to different values. However, I haven't identified any specific use cases where this separate assignment would be necessary, and allowing it might introduce ambiguity.Additional Context
I encountered an error while running the sample project to this line
elsa-core/src/modules/Elsa.Tenants/Services/DefaultTenantResolverPipelineInvoker.cs
Line 20 in 5cb7cbf
Because the app injected the tenant list from a config file with
TenantId
configured but lackingId
, then cause an error while trying to construct a dictionary with missingTenant.Id
. MakingTenant.TenantId
programmatically identical toTenant.Id
could improve the clarity of its usage and prevent similar unexpected errors.I'm open to hearing any considerations I might have overlooked and welcome your opinions on this matter.
Beta Was this translation helpful? Give feedback.
All reactions