I love ORM since it helps development productive and fast. But I was curious how much performance difference there is between Dapper and Entity Framework Core 3.
I used Microsoft’s AdventureWorks database to perform SELECT & INSERT benchmark between Dapper and Entity Framework Core 3. Let ‘s start with SELECT.
SELECT query using Dapper
SELECT query using EF Core 3
SELECT query using EF Core 3 AsNoTracking
I ran the code when the database has only 2000 and 200,000 records in Product table respectively. The winner was…Dapper! even using AsNoTracking() in EF Core. Although the difference might be negligible with AsNoTracking(), if AsNoTracking() is not used, it will cost a lot.
INSERT using Dapper
INSERT using EF Core 3
As expected, EF Core was much slower when it comes to insert.
Conclusion.
EF Core 3 has a lot of good features, and SELECT & INSERT are not the only operations developers need. When it comes to update, EF’s change tracking comes in really handy. However, EF Core’s learning curve is definitively steeper than Dapper and performance is not as good as Dapper. If you or your team member are not familiar with EF Core, I would recommend using Dapper.
The further insertion benchmark follows in this article to even speed up the performance.