EF Core vs Dapper: Which One Should You Choose?
When it comes to database access in the .NET ecosystem, two technologies dominate the conversation:
- Entity Framework Core (EF Core)
- Dapper
A common question among developers is:
Should I use EF Core or Dapper?
The truth is that there is no universal answer. Both technologies solve different problems and excel in different scenarios.
In this article, we'll compare EF Core and Dapper in depth, discuss performance considerations, and identify the best use cases for each.
What is EF Core?
Entity Framework Core is Microsoft's modern Object Relational Mapper (ORM).
It allows developers to interact with databases using C# objects instead of writing raw SQL for every operation.
Example:
var users = await dbContext.Users.ToListAsync();
EF Core automatically translates LINQ expressions into SQL queries.
What is Dapper?
Dapper is a lightweight Micro ORM developed by the Stack Overflow team.
Unlike EF Core, Dapper expects developers to write SQL manually.
Example:
using var connection = new SqlConnection(connectionString);
var users = await connection.QueryAsync<User>(
"SELECT * FROM Users");
Dapper focuses primarily on mapping query results to objects with minimal overhead.
Key Differences
| Feature | EF Core | Dapper |
|---|---|---|
| ORM Type | Full ORM | Micro ORM |
| SQL Writing | Optional | Required |
| Learning Curve | Easy | Moderate |
| Performance | Good | Excellent |
| Migrations | Yes | No |
| Change Tracking | Yes | No |
| LINQ Support | Yes | No |
| Query Control | Moderate | Complete |
| Maintainability | High | Moderate |
Performance Comparison
Performance is where Dapper shines.
Because:
- SQL is executed directly.
- No change tracking overhead.
- No LINQ translation cost.
- Minimal abstraction layer.
- Lower memory allocations.
In large datasets, the difference becomes noticeable.
Example benchmark:
| Technology | Average Execution Time |
|---|---|
| Dapper | 40-80 ms |
| EF Core | 70-150 ms |
Actual results depend on:
- Database engine
- Hardware
- Network latency
- Query complexity
- Data volume
In many business applications, the difference may only be a few milliseconds.
Optimizing EF Core Performance
Many developers assume EF Core is slow.
When used correctly, EF Core can perform remarkably well.
Using AsNoTracking
var users = await dbContext.Users
.AsNoTracking()
.ToListAsync();
This significantly improves read-only query performance.
Projection with Select
Instead of:
var users = await dbContext.Users.ToListAsync();
Use:
var users = await dbContext.Users
.Select(x => new UserDto
{
Id = x.Id,
Name = x.Name
})
.ToListAsync();
Only required columns are retrieved.
Compiled Queries
For frequently executed queries:
private static readonly Func<AppDbContext, int, Task<User?>>
GetUserById =
EF.CompileAsyncQuery(
(AppDbContext db, int id) =>
db.Users.FirstOrDefault(x => x.Id == id));
This can reduce query compilation overhead.
Advantages of Dapper
Maximum Performance
Dapper is one of the fastest data access libraries available for .NET.
Ideal for:
- High-traffic APIs
- Financial systems
- Reporting platforms
- Analytics services
- Real-time applications
Full SQL Control
Developers have complete control over generated queries.
SELECT
u.Id,
u.Name,
COUNT(o.Id) AS OrderCount
FROM Users u
LEFT JOIN Orders o ON o.UserId = u.Id
GROUP BY u.Id, u.Name
No surprises from generated SQL.
Minimal Abstraction
Teams with strong SQL expertise often prefer explicit database access.
Dapper makes this straightforward.
Advantages of EF Core
Faster Development
CRUD operations are extremely productive.
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
Built-in Migrations
dotnet ef migrations add InitialCreate
dotnet ef database update
Database schema management becomes significantly easier.
LINQ Support
var activeUsers = await dbContext.Users
.Where(x => x.IsActive)
.OrderBy(x => x.Name)
.ToListAsync();
Readable and maintainable code.
Change Tracking
Entity modifications are automatically detected.
user.Name = "Updated Name";
await dbContext.SaveChangesAsync();
No manual UPDATE statements required.
When Should You Use EF Core?
EF Core is usually the better choice for:
- Enterprise applications
- ERP systems
- CRM platforms
- Administrative portals
- Internal business applications
- Rapid development projects
- Large development teams
Its productivity benefits often outweigh the performance trade-offs.
When Should You Use Dapper?
Dapper is ideal for:
- High-performance APIs
- Financial applications
- Reporting systems
- Analytics workloads
- Large-scale read operations
- Performance-critical microservices
Hybrid Approach (Most Common in Large Systems)
Many modern applications do not choose between EF Core and Dapper.
They use both.
Example:
- Writes → EF Core
- Reads → Dapper
This pattern is especially common in CQRS architectures.
Commands -> EF Core
Queries -> Dapper
Benefits:
- Faster development
- Better maintainability
- Optimized performance for critical queries
Final Thoughts
EF Core and Dapper are not competitors as much as they are complementary tools.
A simple guideline:
- Need rapid development? → EF Core
- Need maximum performance? → Dapper
- Building a large-scale system? → Use both strategically
Many modern enterprise systems use EF Core as the primary ORM while leveraging Dapper for performance-sensitive queries.
The best choice is not about the technology itself—it's about choosing the right tool for the problem you're solving.