

This in turn can have operations that are easy to be handled by Entity Framework Core, and let’s say a bunch of complex Queries that are meant to be executed by Dapper. But the important detail to take care of is that we need to ensure that both Entity Framework Core and Dapper should participate in the same DB Transaction so that the overall process can be robust.įor example, a particular Write Operation can involve multiple entities and tables. Now, according to our requirement, we need both Entity Framework Core and Dapper to work alongside each other. Important Aspect to Handle – Transactions And finally, the POST Endpoint would take advantage of both these awesome Data Access Technologies and Cleanly Demonstrate Transactions in ASP.NET Core.Īlong the way, we will get introduced to few Libraries for ASP.NET Core that could probably save you some development time as well. The GetById Endpoint would use Entity Framework Core with Eager Loading to display the Department Details as well. For the GetAll Endpoints, we will use Dapper. To demonstrate the usage of Dapper, Entity Framework Core, and both combined, we will implement them each in the 3 Endpoints. You will get a grasp of this once you get to see the Domain Entities. A very imaginary requirement, yeah? 😀 Along with this, we will have 2 other endpoints that return all Employees and Employee by Id.Įxpanding on the details, we will have to ensure the newly added Department does not already exist. To be more clear, every time you add a new employee via the API endpoint, you have to create a new Department Record as well. This company has a policy that says every other Employee has to be linked to a unique Department. We will design a simple ASP.NET Core WebAPI for an Imaginary Company.

So it’s usually Performance and Features when talking about these 2 ORMs. Entity Framework Core is great for class generation, object tracking, mapping to multiple nested classes, and quite a lot more. Dapper is heaven for those who still like to work with RAW Queries rather than LINQ with EFCore.ĭapper is super awesome to handle complex queries that sport multiple joins and some real long business logic. With every update, the performance seems to be improving as well. This does not mean that Entity Framework Core is any slower.

It is always up to the developer to choose between these 2 Awesome Data Access Technologies. It is a straight forward Micro ORM that has minimal features as well.
