Skip to content

Use multiple dbcontext in the same query #4283

Answered by tobias-tengler
Bandude asked this question in Q&A
Discussion options

You must be logged in to vote

From your example you are missing the UseDbContext attribute for the second DbContext. What's happening is that the UseDbContext middleware creates an instance of the DbContext using the factory and pushes it onto the local state in order to make it available to the resolver. The ScopedServiceAttribute is then used to retrieve the instance from the local state. When using the ScopedServiceAttribute you alwqys need to have a call to the UseDbContext middleware with the same DbContext type.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Bandude
Comment options

Answer selected by Bandude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants