EF Core vs Dapper: Performance and When to Use Each

Use EF Core as your default data layer, and use Dapper for hot read queries where you’d rather write the SQL. That’s my verdict on EF Core vs Dapper: EF Core writes SQL and tracks changes, Dapper just maps the rows you query.

On 10,000 US orders in SQL Server, Dapper read one order 1.6x faster than EF Core with AsNoTracking, but EF Core won the 100-row insert. Below is every difference, tested on .NET 10.

EF Core vs Dapper at a Glance

EF Core is Microsoft’s full object-relational mapper. Dapper is a micro-ORM: a set of extension methods on IDbConnection that turn SQL results into objects. I used Microsoft.EntityFrameworkCore.SqlServer 10.0.14 and Dapper 2.1.89, the current stable versions.

FeatureEF CoreDapper
TypeFull ORM (DbContext, DbSet)Micro-ORM (extension methods)
You writeLINQ; SQL optionalSQL strings
Change trackingYes, on by defaultNo
Related dataInclude, navigation propertiesMulti-mapping with splitOn
UpdatesSaveChanges, ExecuteUpdateExecute with your SQL
Schema migrationsYes (dotnet ef)No
Switch databaseChange the providerRewrite dialect-specific SQL
Raw SQLFromSql, SqlQueryAlways
One row by Id (my run)587.9 us tracked, 561.1 us no-tracking355.0 us

If you’re new to EF Core itself, my EF Core tutorial covers the DbContext basics this post builds on.

Sample SQL Server Database for EF Core and Dapper

Every test runs on one model: customers in ten US cities and their orders. Shop.cs holds the entities, the DbContext and the connection string to my local SQL Server (Windows authentication):

using System.Globalization;
using System.Runtime.CompilerServices;
using Microsoft.EntityFrameworkCore;

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; } = "";
    public string City { get; set; } = "";
    public string State { get; set; } = "";
    public List<Order> Orders { get; } = [];
}

public class Order
{
    public int Id { get; set; }
    public int CustomerId { get; set; }
    public Customer? Customer { get; set; }
    public DateTime OrderDate { get; set; }
    public decimal Total { get; set; }
    public string Status { get; set; } = "";
}

public record OrderRow(int Id, string Name, string City, decimal Total);

public class ShopDb : DbContext
{
    public const string Conn =
        "Server=.;Database=w14_efdapper;Trusted_Connection=True;TrustServerCertificate=True";

    public DbSet<Customer> Customers => Set<Customer>();
    public DbSet<Order> Orders => Set<Order>();

    protected override void OnConfiguring(DbContextOptionsBuilder options) =>
        options.UseSqlServer(Conn);

    protected override void OnModelCreating(ModelBuilder b)
    {
        b.Entity<Customer>().Property(c => c.Name).HasMaxLength(100);
        b.Entity<Customer>().Property(c => c.City).HasMaxLength(60);
        b.Entity<Customer>().Property(c => c.State).HasMaxLength(2);
        b.Entity<Order>().Property(o => o.Total).HasPrecision(10, 2);
        b.Entity<Order>().Property(o => o.Status).HasMaxLength(20);
    }
}

static class UsCulture
{
    [ModuleInitializer]   // US dates and currency on any PC
    internal static void Init() =>
        CultureInfo.CurrentCulture = CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
}

Each demo is a .NET 10 file-based app that pulls in Shop.cs with #:include and both packages with #:package. Setup.cs creates the database and seeds 1,000 customers with 10 orders each:

The Pkcs line isn’t a typo. The SQL Server provider pulls in Microsoft.Data.SqlClient 6.1.7, which brings System.Security.Cryptography.Pkcs 9.0.11, and NuGet flags that with NU1903. Pinning 10.0.14 clears it.

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Microsoft.EntityFrameworkCore;

await using var db = new ShopDb();
await db.Database.EnsureDeletedAsync();   // demo database only
await db.Database.EnsureCreatedAsync();

string[] first = ["Jenna", "Tyler", "Maria", "Marcus", "Ashley", "Brandon", "Kayla", "Derek", "Lauren", "Caleb"];
string[] last = ["Morales", "Brooks", "Nguyen", "Carter", "Reed", "Hayes", "Foster", "Bennett", "Price", "Coleman"];
(string City, string State)[] cities = [("Austin", "TX"), ("Denver", "CO"), ("Seattle", "WA"), ("Columbus", "OH"),
    ("Phoenix", "AZ"), ("Atlanta", "GA"), ("Portland", "OR"), ("Nashville", "TN"), ("Boston", "MA"), ("Chicago", "IL")];
string[] statuses = ["Pending", "Shipped", "Delivered"];
var rng = new Random(2026);

for (int i = 0; i < 1000; i++)
{
    var (city, state) = cities[rng.Next(cities.Length)];
    var customer = new Customer { Name = $"{first[i % 10]} {last[i / 10 % 10]}", City = city, State = state };
    for (int j = 0; j < 10; j++)
        customer.Orders.Add(new Order
        {
            OrderDate = new DateTime(2026, 1, 2).AddDays(rng.Next(300)).AddHours(rng.Next(8, 20)),
            Total = rng.Next(1500, 90000) / 100m,
            Status = statuses[rng.Next(statuses.Length)]
        });
    db.Customers.Add(customer);
}
await db.SaveChangesAsync();

Console.WriteLine($"Customers: {await db.Customers.CountAsync():N0}");
Console.WriteLine($"Orders:    {await db.Orders.CountAsync():N0}");
Console.WriteLine($"Revenue:   {await db.Orders.SumAsync(o => o.Total):C}");

Output:

Customers: 1,000
Orders:    10,000
Revenue:   $4,576,576.83

That’s 10,000 orders worth $4,576,576.83. In a real project you’d create the schema with EF Core migrations instead of EnsureCreatedAsync, and keep the connection string in appsettings per environment.

EF Core LINQ vs Dapper SQL: Reading One Row

Same 10,000 orders; we want order 4321. EF Core takes a LINQ expression. Dapper takes the SQL, an anonymous object for the parameter and the result type as a generic argument:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;

int id = 4321;

await using var db = new ShopDb();
Order ef = await db.Orders.AsNoTracking().SingleAsync(o => o.Id == id);
Console.WriteLine($"EF Core: #{ef.Id} {ef.OrderDate:d} {ef.Total:C} {ef.Status}");

await using var cn = new SqlConnection(ShopDb.Conn);
Order dp = await cn.QuerySingleAsync<Order>(
    "SELECT Id, CustomerId, OrderDate, Total, Status FROM Orders WHERE Id = @id", new { id });
Console.WriteLine($"Dapper:  #{dp.Id} {dp.OrderDate:d} {dp.Total:C} {dp.Status}");

Console.WriteLine(db.Orders.Where(o => o.Id == id).ToQueryString());

Output:

EF Core: #4321 4/24/2026 $259.13 Delivered
Dapper:  #4321 4/24/2026 $259.13 Delivered
DECLARE @id int = 4321;

SELECT [o].[Id], [o].[CustomerId], [o].[OrderDate], [o].[Status], [o].[Total]
FROM [Orders] AS [o]
WHERE [o].[Id] = @id
VS Code running ReadOne.cs: EF Core SingleAsync and Dapper QuerySingleAsync both return order 4321, followed by the SQL that EF Core generated
Same order from both; EF Core shows the SQL it wrote

Both returned order 4321: placed 4/24/2026, $259.13, status Delivered. The last lines are the SQL EF Core sent, printed with ToQueryString(). It’s close to the query I typed for Dapper, with the Id as a parameter in both.

That’s the core trade: with Dapper you own the SQL, with EF Core you own the LINQ and trust the translation. My post on how to see the SQL EF Core generates shows the logging options.

EF Core Select Projection vs Dapper SQL Join

Same data again, now the top three Texas orders with the customer’s name and city. EF Core walks the navigation property; Dapper gets a JOIN I wrote:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;

await using var db = new ShopDb();
var ef = await db.Orders.Where(o => o.Customer!.State == "TX")
    .OrderByDescending(o => o.Total).ThenBy(o => o.Id).Take(3)
    .Select(o => new OrderRow(o.Id, o.Customer!.Name, o.Customer.City, o.Total))
    .ToListAsync();
ef.ForEach(r => Console.WriteLine($"EF Core: {r.Id,5} {r.Name,-15} {r.City} {r.Total:C}"));

await using var cn = new SqlConnection(ShopDb.Conn);
var dp = await cn.QueryAsync<OrderRow>("""
    SELECT TOP (3) o.Id, c.Name, c.City, o.Total
    FROM Orders o JOIN Customers c ON c.Id = o.CustomerId
    WHERE c.State = @state ORDER BY o.Total DESC, o.Id
    """, new { state = "TX" });
foreach (var r in dp) Console.WriteLine($"Dapper:  {r.Id,5} {r.Name,-15} {r.City} {r.Total:C}");

Output:

EF Core:  4976 Derek Coleman   Austin $899.86
EF Core:  5800 Caleb Bennett   Austin $899.50
EF Core:  6728 Maria Bennett   Austin $898.76
Dapper:   4976 Derek Coleman   Austin $899.86
Dapper:   5800 Caleb Bennett   Austin $899.50
Dapper:   6728 Maria Bennett   Austin $898.76
VS Code running JoinQuery.cs: EF Core Select projection and a Dapper SQL join return the same top three Texas orders with names, cities and totals
Navigation property vs JOIN, identical rows

Both printed the same three rows, led by order 4976 at $899.86. EF Core turned o.Customer!.State into an INNER JOIN on its own; the LINQ join guide covers explicit joins.

The projection into the OrderRow record matters for speed too. Selecting four columns instead of whole entities is the cheapest EF Core habit you can pick up. (The ! after Customer is the null-forgiving operator from nullable reference types.)

Loading Related Data: Include vs Dapper Multi-Mapping

Now one customer with all ten orders. EF Core has Include; Dapper needs a mapping function that stitches each row into the parent:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;

await using var db = new ShopDb();
var jenna = await db.Customers.AsNoTracking().Include(c => c.Orders).SingleAsync(c => c.Id == 1);
Console.WriteLine($"EF Core Include: {jenna.Name}, {jenna.Orders.Count} orders, {jenna.Orders.Sum(o => o.Total):C}");

await using var cn = new SqlConnection(ShopDb.Conn);
Customer? customer = null;
await cn.QueryAsync<Customer, Order, Customer>("""
    SELECT c.Id, c.Name, c.City, c.State, o.Id, o.CustomerId, o.OrderDate, o.Total, o.Status
    FROM Customers c JOIN Orders o ON o.CustomerId = c.Id
    WHERE c.Id = @id
    """,
    (c, o) => { customer ??= c; customer.Orders.Add(o); return customer; },
    new { id = 1 }, splitOn: "Id");
Console.WriteLine($"Dapper multi-map: {customer!.Name}, {customer.Orders.Count} orders, {customer.Orders.Sum(o => o.Total):C}");

Output:

EF Core Include: Jenna Morales, 10 orders, $4,551.08
Dapper multi-map: Jenna Morales, 10 orders, $4,551.08

Same answer both ways: Jenna Morales, 10 orders, $4,551.08. The Dapper version is longer because the query returns one row per order, and the lambda adds each Order to a single Customer. splitOn: "Id" tells Dapper where the second object starts.

Another Dapper option is two queries and a ToLookup by CustomerId. For one level of children, that’s manageable. Three levels deep (customer, orders, line items) is where I stop writing Dapper mappers and let EF Core do it.

Updates: Change Tracking and ExecuteUpdate vs Dapper Execute

Back to order 5000. EF Core can load it, change a property and save; it can also update many rows without loading them. Dapper just runs an UPDATE:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;

await using var db = new ShopDb();
await using var tx = await db.Database.BeginTransactionAsync();

var order = await db.Orders.SingleAsync(o => o.Id == 5000);
order.Status = "Canceled";
Console.WriteLine($"EF tracked: {db.Entry(order).State}, saved {await db.SaveChangesAsync()} row");

int bulk = await db.Orders
    .Where(o => o.Status == "Pending" && o.OrderDate < new DateTime(2026, 2, 1))
    .ExecuteUpdateAsync(s => s.SetProperty(o => o.Status, "Canceled"));
Console.WriteLine($"EF ExecuteUpdateAsync: {bulk} rows, no entities loaded");

int dp = await db.Database.GetDbConnection().ExecuteAsync(
    "UPDATE Orders SET Status = @status WHERE Id = @id",
    new { status = "Shipped", id = 5000 }, tx.GetDbTransaction());
Console.WriteLine($"Dapper ExecuteAsync: {dp} row");

await tx.RollbackAsync();   // keep the sample data unchanged

Output:

EF tracked: Modified, saved 1 row
EF ExecuteUpdateAsync: 330 rows, no entities loaded
Dapper ExecuteAsync: 1 row
VS Code running UpdateOrders.cs: EF Core reports the tracked entity as Modified and saves 1 row, ExecuteUpdateAsync updates rows without loading entities, and Dapper ExecuteAsync updates 1 row
Tracked save, set-based ExecuteUpdate and Dapper, all in one transaction

The tracked entity showed as Modified, so SaveChangesAsync wrote only the changed column. ExecuteUpdateAsync (EF Core 7+) changed 330 old pending orders in one statement, with no entities in memory.

Dapper’s ExecuteAsync ran on the DbContext’s own connection and transaction, and the rollback at the end undid all three. For bulk updates, ExecuteUpdate removes most of the old reason to drop down to Dapper.

Inserts: SaveChanges vs Dapper Batch Insert

Same customer, 100 new orders. EF Core batches the INSERTs and reads the new identity values back; Dapper runs the statement once per item in the list:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;

List<Order> NewOrders() => [.. Enumerable.Range(0, 100).Select(_ => new Order
    { CustomerId = 1, OrderDate = new DateTime(2026, 11, 20, 9, 30, 0), Total = 49.99m, Status = "Pending" })];

await using var db = new ShopDb();
await using var tx = await db.Database.BeginTransactionAsync();

var efOrders = NewOrders();
db.Orders.AddRange(efOrders);
int ef = await db.SaveChangesAsync();
Console.WriteLine($"EF Core SaveChangesAsync: {ef} rows, every Id filled: {efOrders.All(o => o.Id > 0)}");

int dp = await db.Database.GetDbConnection().ExecuteAsync("""
    INSERT INTO Orders (CustomerId, OrderDate, Total, Status)
    VALUES (@CustomerId, @OrderDate, @Total, @Status)
    """, NewOrders(), tx.GetDbTransaction());
Console.WriteLine($"Dapper ExecuteAsync(list): {dp} rows, Ids not read back");

await tx.RollbackAsync();

Output:

EF Core SaveChangesAsync: 100 rows, every Id filled: True
Dapper ExecuteAsync(list): 100 rows, Ids not read back

EF Core filled every Id on the objects, which you need when you insert a parent and then its children. Dapper returned a row count and left the Ids at 0 unless you add OUTPUT INSERTED.Id yourself.

For tens of thousands of rows, neither is the right tool: use SqlBulkCopy.

Raw SQL in EF Core: FromSql and SqlQuery

EF Core doesn’t force LINQ on you. Same orders table, two raw queries: FromSql for entities (with LINQ composed on top) and SqlQuery for a type that isn’t in the model:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Microsoft.EntityFrameworkCore;

await using var db = new ShopDb();
decimal min = 850m;
int big = await db.Orders.FromSql($"SELECT * FROM Orders WHERE Total > {min}")
    .Where(o => o.Status == "Pending")
    .CountAsync();
Console.WriteLine($"FromSql + LINQ: {big} pending orders over {min:C}");

var states = await db.Database.SqlQuery<StateSales>($"""
    SELECT c.State, COUNT(*) AS Orders, SUM(o.Total) AS Revenue
    FROM Orders o JOIN Customers c ON c.Id = o.CustomerId
    GROUP BY c.State
    """).OrderByDescending(s => s.Revenue).Take(3).ToListAsync();
states.ForEach(s => Console.WriteLine($"SqlQuery: {s.State} {s.Orders:N0} orders {s.Revenue:C}"));

record StateSales(string State, int Orders, decimal Revenue);

Output:

FromSql + LINQ: 187 pending orders over $850.00
SqlQuery: TN 1,140 orders $535,351.99
SqlQuery: CO 1,100 orders $506,958.96
SqlQuery: TX 1,060 orders $489,195.39

FromSql plus a LINQ filter found 187 pending orders over $850.00, and SqlQuery ranked Tennessee first with 1,140 orders $535,351.99. The interpolated {min} became a SQL parameter, so it’s injection-safe. Returning unmapped types like StateSales from SqlQuery needs EF Core 8 or later.

This covers a lot of what people install Dapper for. Stored procedures work the same way; see how to call a stored procedure in EF Core.

Is Dapper Faster Than EF Core? Benchmark Results

For timings I used BenchmarkDotNet 0.15.8 in a Release console project that compiles the same Shop.cs. Every benchmark opens a new DbContext or SqlConnection, the way one web request would:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="..\Shop.cs" />
    <PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
    <PackageReference Include="Dapper" Version="2.1.89" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.14" />
  </ItemGroup>

</Project>
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Dapper;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;

BenchmarkSwitcher.FromAssembly(typeof(ReadOne).Assembly).Run(args);

// Benchmarks return an Id or a row count: BenchmarkDotNet's generated code has its own
// BenchmarkDotNet.Order namespace, so it can't name our Order class in a return type.

static class Sql
{
    public const string ById = "SELECT Id, CustomerId, OrderDate, Total, Status FROM Orders WHERE Id = @id";
    public const string TopN = "SELECT TOP (@rows) Id, CustomerId, OrderDate, Total, Status FROM Orders ORDER BY Id";
    public const string Join = """
        SELECT TOP (100) o.Id, c.Name, c.City, o.Total
        FROM Orders o JOIN Customers c ON c.Id = o.CustomerId
        WHERE c.State = @state ORDER BY o.Total DESC, o.Id
        """;
    public const string Insert = """
        INSERT INTO Orders (CustomerId, OrderDate, Total, Status)
        OUTPUT INSERTED.Id VALUES (@CustomerId, @OrderDate, @Total, @Status)
        """;

    public static async Task<List<Order>> ReadAsync(SqlCommand cmd)
    {
        var list = new List<Order>();
        await using var r = await cmd.ExecuteReaderAsync();
        while (await r.ReadAsync())
            list.Add(new Order { Id = r.GetInt32(0), CustomerId = r.GetInt32(1), OrderDate = r.GetDateTime(2),
                                 Total = r.GetDecimal(3), Status = r.GetString(4) });
        return list;
    }
}

[MemoryDiagnoser]
public class ReadOne
{
    private readonly int id = 4321;
    private static readonly Func<ShopDb, int, Task<Order?>> Compiled = EF.CompileAsyncQuery(
        (ShopDb db, int id) => db.Orders.AsNoTracking().FirstOrDefault(o => o.Id == id));

    [Benchmark] public async Task<int> EfTracked()
    { await using var db = new ShopDb(); return (await db.Orders.FirstOrDefaultAsync(o => o.Id == id))!.Id; }

    [Benchmark] public async Task<int> EfNoTracking()
    { await using var db = new ShopDb(); return (await db.Orders.AsNoTracking().FirstOrDefaultAsync(o => o.Id == id))!.Id; }

    [Benchmark] public async Task<int> EfCompiled()
    { await using var db = new ShopDb(); return (await Compiled(db, id))!.Id; }

    [Benchmark] public async Task<int> EfFromSql()
    {
        await using var db = new ShopDb();
        return (await db.Orders.FromSql($"SELECT * FROM Orders WHERE Id = {id}").AsNoTracking().FirstOrDefaultAsync())!.Id;
    }

    [Benchmark] public async Task<int> DapperQuery()
    { await using var cn = new SqlConnection(ShopDb.Conn); return (await cn.QuerySingleOrDefaultAsync<Order>(Sql.ById, new { id }))!.Id; }

    [Benchmark] public async Task<int> AdoNet()
    {
        await using var cn = new SqlConnection(ShopDb.Conn);
        await cn.OpenAsync();
        await using var cmd = new SqlCommand(Sql.ById, cn);
        cmd.Parameters.Add("@id", System.Data.SqlDbType.Int).Value = id;
        return (await Sql.ReadAsync(cmd))[0].Id;
    }
}

[MemoryDiagnoser]
public class ReadList
{
    [Params(100, 1000)] public int Rows;

    [Benchmark] public async Task<int> EfTracked()
    { await using var db = new ShopDb(); return (await db.Orders.OrderBy(o => o.Id).Take(Rows).ToListAsync()).Count; }

    [Benchmark] public async Task<int> EfNoTracking()
    { await using var db = new ShopDb(); return (await db.Orders.AsNoTracking().OrderBy(o => o.Id).Take(Rows).ToListAsync()).Count; }

    [Benchmark] public async Task<int> DapperQuery()
    { await using var cn = new SqlConnection(ShopDb.Conn); return (await cn.QueryAsync<Order>(Sql.TopN, new { rows = Rows })).AsList().Count; }

    [Benchmark] public async Task<int> AdoNet()
    {
        await using var cn = new SqlConnection(ShopDb.Conn);
        await cn.OpenAsync();
        await using var cmd = new SqlCommand(Sql.TopN, cn);
        cmd.Parameters.Add("@rows", System.Data.SqlDbType.Int).Value = Rows;
        return (await Sql.ReadAsync(cmd)).Count;
    }
}

[MemoryDiagnoser]
public class JoinQuery
{
    private readonly string state = "TX";

    [Benchmark] public async Task<int> EfProjection()
    {
        await using var db = new ShopDb();
        return (await db.Orders.Where(o => o.Customer!.State == state)
            .OrderByDescending(o => o.Total).ThenBy(o => o.Id).Take(100)
            .Select(o => new OrderRow(o.Id, o.Customer!.Name, o.Customer.City, o.Total)).ToListAsync()).Count;
    }

    [Benchmark] public async Task<int> EfInclude()
    {
        await using var db = new ShopDb();
        return (await db.Orders.AsNoTracking().Include(o => o.Customer).Where(o => o.Customer!.State == state)
            .OrderByDescending(o => o.Total).ThenBy(o => o.Id).Take(100).ToListAsync()).Count;
    }

    [Benchmark] public async Task<int> DapperQuery()
    { await using var cn = new SqlConnection(ShopDb.Conn); return (await cn.QueryAsync<OrderRow>(Sql.Join, new { state })).AsList().Count; }
}

[MemoryDiagnoser]
public class Writes
{
    private static Order NewOrder() =>
        new() { CustomerId = 1, OrderDate = new DateTime(2026, 11, 20, 9, 30, 0), Total = 49.99m, Status = "Pending" };
    private static List<Order> NewOrders() => [.. Enumerable.Range(0, 100).Select(_ => NewOrder())];

    [Benchmark] public async Task<int> EfInsertOne()
    { await using var db = new ShopDb(); db.Orders.Add(NewOrder()); return await db.SaveChangesAsync(); }

    [Benchmark] public async Task<int> DapperInsertOne()
    { await using var cn = new SqlConnection(ShopDb.Conn); return await cn.QuerySingleAsync<int>(Sql.Insert, NewOrder()); }

    [Benchmark] public async Task<int> EfInsert100()
    { await using var db = new ShopDb(); db.Orders.AddRange(NewOrders()); return await db.SaveChangesAsync(); }

    [Benchmark] public async Task<int> DapperInsert100()
    {
        await using var cn = new SqlConnection(ShopDb.Conn);
        await cn.OpenAsync();
        await using var tx = await cn.BeginTransactionAsync();
        int n = await cn.ExecuteAsync(Sql.Insert, NewOrders(), tx);
        await tx.CommitAsync();
        return n;
    }

    [Benchmark] public async Task<int> EfUpdateTracked()
    {
        await using var db = new ShopDb();
        var order = await db.Orders.FirstAsync(o => o.Id == 5000);
        order.Total += 0.01m;
        return await db.SaveChangesAsync();
    }

    [Benchmark] public async Task<int> EfExecuteUpdate()
    {
        await using var db = new ShopDb();
        return await db.Orders.Where(o => o.Id == 5000)
            .ExecuteUpdateAsync(s => s.SetProperty(o => o.Total, o => o.Total + 0.01m));
    }

    [Benchmark] public async Task<int> DapperUpdate()
    {
        await using var cn = new SqlConnection(ShopDb.Conn);
        return await cn.ExecuteAsync("UPDATE Orders SET Total = Total + 0.01 WHERE Id = @id", new { id = 5000 });
    }

    [GlobalCleanup] public void Cleanup()     // remove the benchmark's inserts, keep the 10,000 sample orders
    {
        using var cn = new SqlConnection(ShopDb.Conn);
        cn.Execute("DELETE FROM Orders WHERE Id > 10000", commandTimeout: 600);
    }
}

I ran it with dotnet run -c Release -- --filter * --join in the Bench folder, on a quiet PC (CPU load about 19% before the run). Here’s its summary, trimmed to the Mean and Allocated columns:

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.9457/25H2/2025Update/HudsonValley2)
12th Gen Intel Core i7-1260P 2.10GHz, 1 CPU, 16 logical and 12 physical cores
.NET SDK 10.0.402
  [Host]     : .NET 10.0.13 (10.0.13, 10.0.1326.50504), X64 RyuJIT x86-64-v3
  DefaultJob : .NET 10.0.13 (10.0.13, 10.0.1326.50504), X64 RyuJIT x86-64-v3

| Type      | Method          | Rows |        Mean |  Allocated |
|-----------|-----------------|------|-------------|------------|
| JoinQuery | EfProjection    | ?    |  5,730.1 us |  140.65 KB |
| ReadOne   | EfTracked       | ?    |    587.9 us |    94.6 KB |
| Writes    | EfInsertOne     | ?    |  1,204.4 us |  100.27 KB |
| JoinQuery | EfInclude       | ?    |  6,932.3 us |  217.73 KB |
| ReadOne   | EfNoTracking    | ?    |    561.1 us |   94.52 KB |
| Writes    | DapperInsertOne | ?    |    764.0 us |    7.23 KB |
| JoinQuery | DapperQuery     | ?    |  4,808.7 us |   28.54 KB |
| ReadOne   | EfCompiled      | ?    |    472.8 us |    88.1 KB |
| Writes    | EfInsert100     | ?    |  7,776.3 us |  926.71 KB |
| ReadOne   | EfFromSql       | ?    |    716.7 us |   99.54 KB |
| Writes    | DapperInsert100 | ?    | 28,359.5 us |  334.33 KB |
| ReadOne   | DapperQuery     | ?    |    355.0 us |    7.19 KB |
| Writes    | EfUpdateTracked | ?    |  1,535.6 us |   108.5 KB |
| ReadOne   | AdoNet          | ?    |    368.4 us |    6.66 KB |
| Writes    | EfExecuteUpdate | ?    |    899.2 us |   91.99 KB |
| Writes    | DapperUpdate    | ?    |    510.9 us |    4.67 KB |
| ReadList  | EfTracked       | 100  |  1,048.2 us |  194.45 KB |
| ReadList  | EfNoTracking    | 100  |    625.4 us |   129.1 KB |
| ReadList  | DapperQuery     | 100  |    316.8 us |   29.34 KB |
| ReadList  | AdoNet          | 100  |    290.3 us |   18.77 KB |
| ReadList  | EfTracked       | 1000 |  2,728.8 us | 1136.86 KB |
| ReadList  | EfNoTracking    | 1000 |  1,668.7 us |  476.76 KB |
| ReadList  | DapperQuery     | 1000 |  1,150.0 us |  226.23 KB |
| ReadList  | AdoNet          | 1000 |  1,199.4 us |  168.45 KB |

One row by Id: Dapper took 355.0 us and allocated 7.19 KB. EF Core took 587.9 us tracked and 561.1 us with AsNoTracking, allocating about 94.52 KB. Most of that 1.6x gap is fixed per-query work: DbContext setup, query-cache lookup and materializing.

A compiled query (EF.CompileAsyncQuery) brought EF Core down to 472.8 us, which skips the query-cache lookup. FromSql came in at 716.7 us.

Lists: for 1,000 orders Dapper took 1,150.0 us vs 1,668.7 us (no tracking) and 2,728.8 us (tracked). Tracking more than doubled the memory: 1136.86 KB vs 476.76 KB. For read-only lists, AsNoTracking is free speed.

Join: on the Texas join, the database did most of the work, so the gap shrank to 1.2x: 4,808.7 us for Dapper, 5,730.1 us for the EF Core projection and 6,932.3 us with Include, which loads whole entities.

Writes: one insert took 764.0 us with Dapper vs 1,204.4 us with SaveChanges. Updating order 5000 took 510.9 us with Dapper, 899.2 us with ExecuteUpdate and 1,535.6 us the tracked way (load, change, save: two round trips).

The 100-row insert flipped the result: EF Core took 7,776.3 us and Dapper 28,359.5 us. Dapper’s list overload runs the INSERT once per item (100 round trips), while SaveChanges batches the statements into a few commands.

Important: these numbers come from one machine with SQL Server on the same box. Treat the ratios as the result, not the microseconds. Over a real network, the round trip adds the same time to both, so the relative gap shrinks.

EF Core vs Dapper vs ADO.NET

Dapper sits on top of ADO.NET, so the honest baseline is a raw SqlDataReader. Same order 4321, read by hand:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using System.Data;
using Microsoft.Data.SqlClient;

await using var cn = new SqlConnection(ShopDb.Conn);
await cn.OpenAsync();
await using var cmd = new SqlCommand(
    "SELECT Id, CustomerId, OrderDate, Total, Status FROM Orders WHERE Id = @id", cn);
cmd.Parameters.Add("@id", SqlDbType.Int).Value = 4321;

await using var reader = await cmd.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
    var o = new Order
    {
        Id = reader.GetInt32(0), CustomerId = reader.GetInt32(1), OrderDate = reader.GetDateTime(2),
        Total = reader.GetDecimal(3), Status = reader.GetString(4)
    };
    Console.WriteLine($"ADO.NET: #{o.Id} {o.OrderDate:d} {o.Total:C} {o.Status}");
}

Output:

ADO.NET: #4321 4/24/2026 $259.13 Delivered

It printed the same row as the EF Core and Dapper versions. In the benchmark, ADO.NET took 368.4 us for one row against Dapper’s 355.0 us, and 1,199.4 us vs 1,150.0 us for 1,000 rows. Dapper costs almost nothing over hand-written reader code.

So I don’t write raw ADO.NET for queries anymore: Dapper is as fast with far less code. ADO.NET still fits SqlBulkCopy and streaming huge result sets. The async/await guide explains the Async calls used here.

Can You Use EF Core and Dapper Together?

Yes, and it’s the setup I use most. Dapper’s methods extend any DbConnection, including the one EF Core already opened. Same customer, an EF Core insert and a Dapper report inside one transaction:

#!/usr/bin/env dotnet
#:package Microsoft.EntityFrameworkCore.SqlServer@10.0.14
#:package Dapper@2.1.89
#:package System.Security.Cryptography.Pkcs@10.0.14
#:property PublishAot=false
#:include Shop.cs

using Dapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;

await using var db = new ShopDb();
await using var tx = await db.Database.BeginTransactionAsync();

db.Orders.Add(new Order { CustomerId = 1, OrderDate = new DateTime(2026, 11, 20, 10, 15, 0),
    Total = 129.95m, Status = "Pending" });
await db.SaveChangesAsync();                       // write with EF Core

var report = await db.Database.GetDbConnection().QuerySingleAsync<(string Name, int Pending)>("""
    SELECT c.Name, COUNT(*) FROM Customers c JOIN Orders o ON o.CustomerId = c.Id
    WHERE c.Id = @id AND o.Status = 'Pending' GROUP BY c.Name
    """, new { id = 1 }, tx.GetDbTransaction());  // read with Dapper, same transaction
Console.WriteLine($"Dapper sees the EF Core insert: {report.Name} has {report.Pending} pending orders");

await tx.RollbackAsync();

Output:

Dapper sees the EF Core insert: Jenna Morales has 6 pending orders
VS Code running EfCoreWithDapper.cs: EF Core saves a new pending order and a Dapper query on the DbContext connection and transaction sees it
Dapper on the DbContext’s connection sees EF Core’s uncommitted insert

Dapper sees the EF Core insert: Jenna Morales has 6 pending orders, read straight into a named tuple. Because the Dapper query passed tx.GetDbTransaction(), it saw the uncommitted row. Leave the transaction out and SqlClient throws, because the connection already has a pending local transaction.

In ASP.NET Core, inject the DbContext into a small query class that calls db.Database.GetDbConnection(). Both then share one scoped connection per request, as the DI lifetimes post explains. My Web API CRUD tutorial is a good base to add it to.

When to Use Dapper Instead of EF Core

  • CRUD screens, business rules, relationships and migrations: EF Core.
  • A read endpoint that runs thousands of times a minute and returns a flat projection: Dapper (or EF Core with AsNoTracking and a compiled query, then measure).
  • Reports, dashboards and complex SQL your DBA already tuned: Dapper, or EF Core’s SqlQuery if the project has no Dapper yet.
  • Bulk updates and deletes: EF Core’s ExecuteUpdate and ExecuteDelete. For huge inserts: SqlBulkCopy.
  • A legacy database with odd naming and lots of stored procedures, no EF model yet: Dapper.

More data-access posts live on the ASP.NET Core tutorials hub. Before you rewrite queries for speed, check whether the result can be cached. A HybridCache hit beats any ORM.

The deciding differences: EF Core writes the SQL, tracks changes and migrates the schema; Dapper runs your SQL with almost no overhead. Start with EF Core, and add Dapper to the queries your profiler points at.

Building out the data layer? These pair well with this comparison:

Frequently Asked Questions

Is Dapper faster than EF Core?

In my BenchmarkDotNet run on .NET 10, yes: one row by Id took 355.0 us with Dapper vs 587.9 us with tracked EF Core and 561.1 us with AsNoTracking. The gap is real but small next to network and database time, so measure your own queries.

Is Dapper an ORM?

It’s a micro-ORM. It maps query results to objects and parameters to SQL, but it has no change tracking, relationships or migrations. The Dapper project on GitHub lists its extension methods.

Does Dapper prevent SQL injection?

Yes, when you pass values as parameters (new { id }) instead of concatenating strings. Dapper sends them as SQL parameters. Building SQL with string interpolation inside a Dapper call is just as unsafe as anywhere else.

Is EF Core FromSql safe from SQL injection?

FromSql and SqlQuery turn interpolated values into DbParameters, so they’re safe. FromSqlRaw and SqlQueryRaw aren’t, if you concatenate input. See the Microsoft Learn page on SQL queries.

Can I use Dapper with EF Core migrations?

Yes. Let EF Core own the schema and migrations, and point Dapper at the same database through the DbContext’s connection or the same connection string.