-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Using Multitenant inside a Hangfire batch #485
Comments
Hi I'm not familiar with Hangfire jobs, but I think I can see what is happening. The DbContext(s) are being spun up with a null Is it possible that you can break up your bulk edit into bulk edit by tenant and for each one spin up a dbcontext with a |
I've kind of the same problem. As I could research about this, TenantInfo is stored over HttpContext but HangFire doesn't use HttpContext... :(. Any alternative to store TenantInfo in some other place? For now I solved this doing HangFire make a HTTP request back to my API, but I think this is not optimal ... API -> HangFire -> API |
Hi, |
I'm assuming this happens because the background job is using something that has a dependency on a If so, can the job be rewritten to remove that dependency, since it sounds like what you're doing isn't really tenant-specific? For my Hangfire jobs, I try to make them as atomic as possible - this allows me to enqueue them in a few different contexts (within ASP.NET Core and within TopShelf-enabled background services, for example) without adding a lot of transitive dependencies. (Sorry, wasn't paying attention to the issue date - this was probably resolved a while ago) |
Hello,
We have an issue using multitenant inside Hangfire batch. We are using multitenant in header strategy and when we are in controllers everything is fine.
But for some reasons we have to bulk edit some entities asynchronously, for that we are using Hangfire jobs.
The entity to update is a multitenant entity and inside hangfire job the HttpContext is not valued because we are not in a HttpRequest... All the time the DbContext is raising an exception "MultiTenant Entity cannot be changed if TenantInfo is null.". We are only in update mode and we d'ont have to update the tenant because we are tenant scoped.
What can we do to achieve this ?
Thanks
The text was updated successfully, but these errors were encountered: