© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
67 replies
Exi

✅ BlazorWASM Multi Tenant / Multi Tenancy

Hello,
I'm currently trying to implement multi tenancy to my blazor application and I could need a hand.

The User should be able to select a tenant at runtime and the new querys should use that new/updated tenant.
I browsed the internet a lot and found a lot of variants, but still not sure what's the best for me and also failed on implementing them xD

Currently I'm storing the tenant information in my appsettings and created a TenantService to set the tenant and receive the connectionstring.
My DbContext uses the service to get the current connectionstring (in theorey)
I registered my ContextFactory in the program.cs
Image is added how I use my context for example in my repo.
I'm trying to switch the tenant from the frontend via an api call.

I think my problem is the lifetime or smth, because I can switch the tenant and that settenant works, but if I use a new query it seems like the new instance of my context uses the default value, because the "updated tenant" isnt remembered. Sorry for my noob terms, I'm new to that and hope you can understand me :D

I'd be happy about some help and maybe some input for my knowledge and understanding. Thank you

Greetings
Exi
image.png
image.png
image.png
image.png
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements
Next page

Similar Threads

❔ BlazorWASM Multi-Tenant Application - Struggle with changing DbContext while Runtime
C#CC# / help
3y ago
❔ Multi-tenant == Roles ?
C#CC# / help
4y ago
❔ Multi-tenancy - database per tenant - which database(s) to store Users?
C#CC# / help
3y ago
Multi tenant implementation & Security
C#CC# / help
12mo ago