C
C#10mo ago
G1lles

ASP.NET Core - DbContext UOW with strict n-tier architecture

I am using Entity Framework Core with an n-tier architecture (persistence, business & application layer). I am attempting to create a Unit of Work class for my MVC application. Ideally, I would use the Unit of Work instance in my controller. However, when trying to create my unit of work, I would need to use my repositories directly, but that would violate my architecture because then I would interact with the repositories directly instead of through my managers. Hence, we came up with a possible "solution" to use my managers in my unit of work, but as you might've guessed already.. how would I then make sure all of my managers use the same DbContext? I wonder if there is any way to make it work correctly, without violating the architecture.
1 Reply
Jimmacle
Jimmacle10mo ago
a dbcontext is already a unit of work and you shouldn't have (generic) repositories on EF core either, because DbSet<T> is already a generic repository don't let the architecture force you to write weird code just to conform to the architecture
Want results from more Discord servers?
Add your server