© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
3 replies
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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

.NET Core DBContext
C#CC# / help
2w ago
svelte with asp.net core
C#CC# / help
2y ago
✅ ASP.NET Core DI: DbContext Not Shared in Scoped Services
C#CC# / help
7mo ago