Join the conversation

Sign in to join this conversation, and others like it, in the communities you care about.

ASP.NET Core

Discuss anything related to ASP.NET Core and solve the problem together.

ASP.NET Core / General

Dapper VS EF Core

Dapper VS EF Core

ASP.NET Core / General · June 15, 2019 at 6:46am (Edited 6 years ago)

I like to call it as comparing of an auto-generated SQL to the one written by a good developer.

In Dapper it is simply

using (IDbConnection db = new SqlConnection(@"YourConnectionString"))
{
return db.Query
($"select top 5000 * from users").ToList();
}

In EF Core, we can do in either ways. From SQL or letting the library generate the query.

using (var db = new EFCore2TestContext())
{
return db.Users.FromSql("Select top 5000 * from users").AsNoTracking().ToList();
//return db.Users.Take(5000).AsNoTracking().ToList();
}
DapperVsEFCore.png

Looking in to the results, we can say Dapper is faster than the Entity Frame Core 2. And it is a matter of peoples' interest. If performance is your biggest concern, Use dapper. And if the concern is in saving development time, use entity framework instead with compromising a little bit on performance.

courtesy : https://medium.com/@engr.mmohsin/entity-framework-core-2-dapper-performance-benchmark-c29e8cce9e1b

emoji
No messages have been sent in this conversation yet—why don’t you kick things off below?