Architecture is a complicated and controversial theme. There is no "silver bullet" that solves everything.
Many people are against using a repository when using a ORM because it offers many facilities in accessing and operating data and creating a repository causes repetitive printing.
I don’t agree with this approach because you’re delegating all your data manipulation to a framework. This may cause future performance-related problems with large, illegible, and difficult to debug Lambda / large queries.
There are other factors that motivate using the repository and other layers in a system that is the writing of tests. If you, for example, put data access and business rule resolution in the domain layer you will probably write large and complex methods making it impossible to write unit tests.
A classic layered web application usually contains the following layers (remember that there may be several other architectural solutions):
User Interface (User Interface)
Layer where user iteration occurs
Application ()
Another polemical layer. In it you treat your interface rules as, for example, turn a Model into Viewmodel and vice versa.
Domain ()
In this layer you solve the business rules of the application how to perform certain calculation according to the data informed by the user, calculate the percentage to debit from a sale etc.
Repository ()
Here you only treat data access. The domain layer "delivers" the "ready" domain objects so you can only perform database operations.
This is just one example of architecture that is very common, but as I said in the beginning there is no silver bullet for everything. Before starting development, any system should try to understand the requirements of the application to create an adhering architecture that meets the needs of the application, be easy to understand and develop.
Remember that we have several other types of architecture as based on microservices, messaging among others.
Take a look in this talk that talks about the architecture of Stackoverflow.
This is very relative, it depends on the architecture you are deciding to use. But since you mentioned the layers, if you wanted to separate them by layers, I would make a unique data access, containing Uow. Leaving the service layer unique to the rules of business, and through the service would call the repository.
– Renan Carlos
This is exactly how I’ve been developing my projects! Actually the question is more because I read several people who seem to have a certainty on the subject (of not using Unit of Work + Repository +Dbcontext), and so far I do not understand where it comes from....
– Andre