Which ORM is better for your .NET project? 𝗘𝗙 𝗖𝗼𝗿𝗲 - 𝗗𝗮𝗽𝗽𝗲𝗿
Let's compare them on: Level of abstraction Performance Features 𝗟𝗲𝘃𝗲𝗹 𝗼𝗳 𝗔𝗯𝘀𝘁𝗿𝗮𝗰𝘁𝗶𝗼𝗻 EF Core is a higher-level ORM that abstracts away much of the underlying database structure, allowing you to work with your data using a more object-oriented approach. This can make it easier to work with, especially if you're new to databases or dealing with a complex data model. On the other hand, Dapper is a more lightweight ORM that provides a minimal amount of abstraction over your database. This means that you'll have more control over the SQL queries that are executed, which can be helpful if you want to optimize the performance of your queries. However, it also means that you'll need to understand the underlying database structure well and be comfortable working with raw SQL queries. 𝗣𝗲𝗿𝗳𝗼𝗿𝗺𝗮𝗻𝗰𝗲 Dapper provides less abstraction and can be faster than EF Core when executing complex queries. Dapper runs SQL queries you provide from your code, whereas EF Core generates them based on the data model you've defined. Although EF 8 will have raw SQL support, similar to Dapper. Performance isn't on par yet. It's worth noting that the performance difference between EF Core and Dapper is not always significant, and in some cases, EF Core can be just as fast as Dapper. 𝗙𝗲𝗮𝘁𝘂𝗿𝗲𝘀 EF Core includes support for a wide range of features: LINQ queries Migrations Multiple database providers Change tracking (unit of work) On the other hand, Dapper is a more focused tool primarily designed for working with data. It includes support for mapping objects to SQL queries and executing them and support for custom SQL queries and stored procedures. Overall, you can see they're fundamentally different libraries. So is it even worth comparing them? I think yes, to at least understand the fundamental differences. But here's what I do in my applications. I choose to work with 𝗯𝗼𝘁𝗵 EF Core and Dapper. For example, I use EF Core on the write side with my rich domain model. And Dapper on the read side for simplified mapping and better query performance.