ORM Dapper vs Entity framework

MHD
2 min readJun 26, 2020

--

Dapper

Dapper is a simple object mapper for .NET and own the title of King of Micro ORM in terms of speed and is virtually as fast as using a raw ADO.NET data reader.

EF

Entity Framework is the set of .NET APIs for performing data access in your Applcation, and EF is the official data access tooling from Microsoft.

Comparison

  • Dapper is currently considered the king of Micro ORMs regarding performance and the number of NuGet downloads.
  • While Entity Framework is considerately slow as compared to Dapper.
  • Dapper is not doing as much as other ORMs, such as the Entity Framework, regarding generating SQL, but Dapper does do a fantastic job mapping from database columns to properties of CLR objects.
  • Dapper is a little bit harder to code due to RAW SQL queries and especially when the number of relationships exists, but the effort is worth it when lots of data and performance is important.
  • Dapper is using directly IDbConnection which provides smoothness and execute SQL query to the database directly instead of using data in the form of other objects as developers do in Entity Framework.
  • Dapper was written with speed as a priority and the tests definitely prove this out.
  • EF is not good for a huge domain model.
  • The EF queries are generated by the provider that we cannot control.
  • Dapper can’t generate a class model for you
  • Dapper can’t generate queries for you

Conclusion

the two frameworks are object-relational mapping framework and all of them have pros and cons, and the using one of them dependent on your Requirements .

--

--