-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support multiple DbContext #2
Comments
Hmm. Off the top of my head, we could change We could then implement a second Then we could utilize something like context based injection to differentiate between the unit of works. That, or make UnitOfWork a generic class to specify the type of DatabaseFactory it should inject. Thoughts? |
My mistake! Your first idea is great, I didn't know the context based injection concept as I'm using autofac (I'll have to check if they have a similar approach, because the other solutions they present end up leaking the IoC container into the Core Layer). If I'm understanding correctly, the second approach means that the However, the current interface of |
@pfaustinopt Sorry for the delay in response - you're right, This StackOverflow question discusses a lack of Otherwise, other options include replacing Entity Framework with Dapper or options I haven't considered yet. |
Hello again,
I was trying a different strategy with your architecture, which is separating the DbContext into multiple DbContexts (I'm trying to apply some DDD patterns).
However, I'm not having an easy time with IUnitOfWork because it is coupled with the AcmeDataContext. I was thinking about creating a IUnitOfWork where T could be a DbContext, but this means that the Core layer would need to have a reference to Entity Framework, which I was avoiding.
Do you have any ideas on how to decouple IUnitOfWork from AcmeDataContext while still being capable of using IoC to register multiple DbContexts?
The text was updated successfully, but these errors were encountered: