Open devalot76 opened 3 years ago
hi, excellent question and I must admit I do not know off the top of my head. I will flag this and investigate. If you have experimented please let me know your findings.
After looking into this I have to recommend against using the db context pool for exactly the reason you mentioned.
If you have a fancy db context that was smart enough to somehow validate its ITenantInfo
member this could work but that is not something I'm planning to prioritize at the moment. Thanks again for the question.
@natelaff I saw you had a comment on here.
It occurred to me the pooled context stuff might work if IMultiTenantContextAccessor
is injected into the db context instead of ITenantInfo
depending on the aspnet internals it might work -- would have to be tested.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Just a quick bump on this question. I see its been marked as stale, but as luck would have it, im in the same boat right now too. (Wanting to use HotChocolate (with a pooledbcontext) + Finbuckle)
I'll do some r&d into this as well, since its a bit of a core requirement for us, but I'm reaching out in the hopes that there has been some learnings since this question was created @AndrewTriesToCode 🙏 (Also major thank you for a great multi T lib, we've been using it for quite some time now and it works great.)
hi, I unfortunately haven't tested out this use case yet so any help is appreciated. The main issue I see is how much of a db context configuring is "locked in" during its initialization. If you are using the same connection string for all tenants and just changing the TenantInfo
this very well could work since the global query filter is dynamic to check the TenantId
for each query.
If tenants have different connection strings or even different database providers things get much more complicated. I assume some of the details are baked in during instantiation and can't be changed after the fact -- basically anything in your OnConfiguring
method.
Yeah this was where I tapped out of it and ran out of time. My connection strings are different per tenant. I would have loved to investigate more as this seems soooo much nicer than REST, but I am on an already delayed timeline :) Please share findings!
Hello, I'm in the same situation. Want to use HotChocolate with Finbuckle and I really need PooledDbContext because of problem in DataLoader. Any new or plan to use Pooled Db Context?
Hi and happy new year! I was wondering, is it safe to use .AddDbContextPool() instead of .AddDbContext() or could there be issues with tenants since the first method reuses instances of the DbContext?
My configuration is:
Thanks.