Entity Framework  

EF Core vs Dapper in .NET 10

Introduction

In the .NET ecosystem, Entity Framework Core (EF Core) and Dapper are two of the most popular data access technologies.
Both are powerful, but they serve different purposes.

In this article, we’ll cover:

  • What EF Core is

  • What Dapper is

  • Key differences between EF Core and Dapper

  • .NET 10 code examples for both

  • When to use which (real-world guidance)

What is EF Core?

Entity Framework Core is a full-featured ORM (Object Relational Mapper).
It allows developers to work with databases using C# objects instead of raw SQL.

Key Features of EF Core

✔ LINQ-based querying
✔ Change tracking
✔ Migrations
✔ Relationship management
✔ Faster development for CRUD apps

When EF Core is a Good Choice

  • Business applications

  • CRUD-heavy systems

  • Rapid application development

  • Applications with complex relationships

What is Dapper?

Dapper is a Micro ORM developed by Stack Overflow.
It is essentially a high-performance wrapper over ADO.NET.

Key Features of Dapper

✔ Extremely fast
✔ Full SQL control
✔ Excellent support for stored procedures
✔ Minimal abstraction

When Dapper is a Good Choice

  • High-performance systems

  • Banking or financial applications

  • Stored procedure–based databases

  • Read-heavy applications

FeatureEF CoreDapper
TypeFull ORMMicro ORM
PerformanceModerateVery High
SQL ControlLimitedFull
Learning CurveMediumLow
Stored ProceduresSupportedExcellent
Change TrackingYesNo
Best Use CaseBusiness appsPerformance-critical apps

EF Core Example

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public decimal Balance { get; set; }
}

DbContext

public class AppDbContext : DbContext
{
    public DbSet<Customer> Customers => Set<Customer>();

    public AppDbContext(DbContextOptions<AppDbContext> options)
        : base(options) { }
}

Program.cs

builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("Default")));

Query Using EF Core

app.MapGet("/customers", async (AppDbContext db) =>
{
    return await db.Customers
                   .Where(c => c.Balance > 1000)
                   .ToListAsync();
});

Pros

  • Clean and expressive

  • Easy to maintain

Cons

  • Slight performance overhead for large datasets

Dapper Example

Repository

public class CustomerRepository
{
    private readonly IDbConnection _db;

    public CustomerRepository(IConfiguration configuration)
    {
        _db = new SqlConnection(configuration.GetConnectionString("Default"));
    }

    public async Task<IEnumerable<Customer>> GetCustomersAsync()
    {
        var sql = """
                  SELECT Id, Name, Balance
                  FROM Customers
                  WHERE Balance > @Balance
                  """;

        return await _db.QueryAsync<Customer>(
            sql,
            new { Balance = 1000 }
        );
    }
}

Register Service

builder.Services.AddScoped<CustomerRepository>();

Minimal API Endpoint

app.MapGet("/customers-dapper", async (CustomerRepository repo) =>
{
    return await repo.GetCustomersAsync();
});

Pros

  • Extremely fast

  • Full control over SQL

  • Ideal for stored procedures

Stored Procedure Example with Dapper

public async Task<Customer?> GetCustomerByIdAsync(int id)
{
    return await _db.QueryFirstOrDefaultAsync<Customer>(
        "usp_GetCustomerById",
        new { Id = id },
        commandType: CommandType.StoredProcedure
    );
}

Which One Should You Use?

Use EF Core if:

  • You are building ERP, CRM, or admin systems

  • Rapid development is important

  • You rely heavily on entity relationships

Use Dapper if:

  • Performance is critical

  • Your database is stored-procedure driven

  • You are building financial or reporting systems

  • You need precise SQL control