Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TKey for TenantId column #845

Open
Leon99 opened this issue Jun 23, 2024 · 3 comments
Open

Use TKey for TenantId column #845

Leon99 opened this issue Jun 23, 2024 · 3 comments
Labels

Comments

@Leon99
Copy link

Leon99 commented Jun 23, 2024

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
Copy link
Contributor

AndrewTriesToCode commented Jun 25, 2024

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
Copy link
Author

Leon99 commented Jun 26, 2024

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?

@AndrewTriesToCode
Copy link
Contributor

I don't have a good example to share unfortunately. I recommend isolating such a change to the database via ef setup as described in the link above to minimize any other potential problems. However I would first make sure that using strings is in fact impacting performance before worrying about it too much

One thing you can do is in your tenant creation logic use a guid as the ID which is saved and used as a string-- that is what ASP.NET Core Identity does (of course it lets you use your own key type...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants