Entity Framework Versus Dapper


Comparison of Dapper Versus EntityFramework


Being authored an authorization server for Multi-Tenant SaaS Applications, one fine day, I was doing application profiling and noticed in profiler, that the context loading was taking more time, rather than rewriting the same in ADO.Net for critical requests that are required to handle data faster, I thought I would opt for Dapper.

Dapper had a simple wrapper over the SQL Connection that takes the Query and the paramters [SQL Paramters for parameterized Query]. I found dapper simple and interesting. Deciding to try out Dapper in a similar environment than replacing in the exising ones, I did a couple of benchmarks of Dapper Versus EntityFramework and the following are the observations.

Method Job Jit Mean Error StdDev Median
GetClientDetailFromDapperDAL_Async LegacyJitX64 LegacyJit 243.2 us 4.817 us 5.354 us 243.8 us
GetClientDetailFromEFDAL_Async LegacyJitX64 LegacyJit 465.5 us 9.258 us 24.390 us 457.1 us
GetClientDetailFromDapperDAL_Async RyuJitX64 RyuJit 237.6 us 2.447 us 2.169 us 237.6 us
GetClientDetailFromEFDAL_Async RyuJitX64 RyuJit 465.6 us 9.022 us 12.940 us 465.1 us

The source code for this analysis will be posted shortly.

Advertisements