Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.26k stars 256 forks source link

Use TKey for TenantId column #845

Open Leon99 opened 1 week ago

Leon99 commented 1 week ago

It looks like IsMultiTenant() is hard-coded to use string for TenantId column. I'm curious as to why not use TKey instead? In most cases I'd rather use Guid for storing tenant Ids.

AndrewTriesToCode commented 1 week ago

Hi, it was a design decision that fit the original use case I had long ago and now I’m stuck with it. I plan to abstract it out but it involves changes almost everywhere in the code. It also makes using the library messier since you have to pass your key around everywhere.

For EFCore purposes there are value conversions which can help: https://learn.microsoft.com/en-us/ef/core/modeling/value-conversions

Leon99 commented 1 week ago

you have to pass your key around everywhere

Could you give an example? I’m thinking of making the change myself, but don’t want to end up introducing another issue or maintaining a separate fork. Would you suggest using EF value conversions instead?