While the .Net Core 2.0 is still being baked (Preview 3 is out now!), I thought I’d give the Entity Framework Core 2.0 a try and do a benchmark and compare it to Dapper.Net.

So without further rant, lets get to it:

Database Setup:

I used SQL Azure, just because it is easy to setup the AdventureWorks sample DB there quickly. For this benchmark I will only use the Product and Product category tables.

Entity Framework Core 2.0 Repository

Here how the Entity Framework Core 2.0 query looks like:

Dapper.Net Repository

Here is how the Dapper.Net query looks like:

Benchmark Class

For the benchmark, I usually use the Benchmarkdotnet.org. So here is how my benchmark class looks like:

Running the Benckmark

Here is how I run the benchmark in my .Net Core 2.0 Console Application:

Benchmark result

Aaaaand the winner is: Dapper.net (barely!)

As you see in the above window, dapper’s number is better by 0.05 milliseconds in Standard deviation of all measurements.

Source Code

If you want to play with the benchmark and add some more comparisons to it you can find it here: