I’m looking to implement something like option 2 in this article. I really appreciate your insights and they help me on my journey and thank you for taking the time to do that. 2. So I created a class (I am not sure what to call it, but I call it an adapter), which has an interface, and exposes my domain entities (I do not consider them database entities) from the DbSet. Don’t do this or else you’ll have some crusty Carmudgeon on your back! As we have seen, we need to share the DbContext. Which gave the impression that the two patterns operate separately. There is a GitHub repo that goes with my book at https://github.com/JonPSmith/EfCoreInAction. For both of us we have to find patterns that stops large systems turning into a ball of mud. If you have found a good way to use the repository pattern with EF Core then that’s great. The points he mentioned in the post are perfectly valid reasons to avoid this particular pattern. This site uses Akismet to reduce spam. We will also do a little re-factoring by changing the repository to stop having automatically a call to SaveChanges. 2. I’m glad my ramblings help you along the way. SqlClient for .NET Core 2.0 will throw an exception if you attempt to use the feature. Although support is quite common among ADO.NET providers for .NET Framework, the API has only been recently added to .NET Core and hence support is not as widespread. Post was not sent - check your email addresses! Although for the most part, Version 4 was a considerable improvement. Repositories are simply a place to define and encapsulate business rules, in classic application architecture, they are the middle tier or business layer, sure by all means do away with them and replace them with something not called a repository, but don’t fool yourself into thinking there’s no use for them. Use AddScoped method instead of AddTransient, I agree with @Rabban comment. So, should I create method GetCategories() in the AnimalService or create CategoryService and define in it? The 2nd. You can see this in action on the live site http://efcoreinaction.com/. The first step is to create a repository class for animal inside the DataAccessLayer folder. Many applications rely on good, fast queries such as, a list of products to buy, a list of things to do, and so on. Inside handlers I am using transactions for DB operation. Simplified: Can I (and should I) create a transaction inside the service method, save changes there, and commit it only if SaveChanges is called successfully from the calling controller? Creating Domain-Driven Design entity classes with Entity Framework Core. Then later, I will show you how to use the repository pattern and unit of work in CQRS with MediatR. The use case for Changing or Swapping ORM’s hardly ever comes to fruition! Generally, it is a good idea to expose your Repository layer to a Service layer, which then provides domain entity objects to the UI & Business Layer. Writing straightforward EF Core queries is really easy so a repository doesn’t add much. If you want to add validation that are executed by EF with more logic on it, I suggest you to have you entity inherit the IValidatableObject and add your logic into this method. Turns out I over complicating the bindings.