How to handle background process #61
-
Hello John, Many thanks for your opinion! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As you know background processes don't have a valid user for obvious reasons. I would suggest you create the DbContext manually in your background process. You would need to obtain the using var context = new YourTenantDbContext(optionsViaDi, "The correct DataKey for the tenant you want to access") |
Beta Was this translation helpful? Give feedback.
As you know background processes don't have a valid user for obvious reasons. I would suggest you create the DbContext manually in your background process. You would need to obtain the
DbContextOptions<YourTenantDbContext>
service via DI and then use the code below to create theYourTenantDbContext
.