Use multiple dbcontext in the same query #4283
-
Beta Was this translation helpful? Give feedback.
Answered by
tobias-tengler
Sep 29, 2021
Replies: 1 comment 1 reply
-
From your example you are missing the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Bandude
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.