✅ 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
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





