## The Decision That Changed My Backend Thinking
When I started building my personal portfolio, I had a choice — Entity Framework (my comfort zone) or Dapper (something I had been curious about). I chose Dapper. Here's what I learned.
## What I Was Building
My portfolio has two modules — a public-facing website and an admin panel for managing content. The data layer needed to handle projects, skills, experiences, blogs, and contact messages. Simple CRUD — but performance mattered since this was going on a public URL.
## Entity Framework — What I Knew
I had used EF extensively at Traviyo and Preview Technologies. It's powerful — migrations, LINQ queries, change tracking — everything works out of the box.
**But here's what bothered me:**
- Generated SQL is often bloated
- For simple queries, it carries too much overhead
- Debugging "why is this query slow" is painful
- Heavy for read-heavy applications
## Dapper — First Impressions
Dapper is a micro-ORM built by the Stack Overflow team. It extends IDbConnection and maps SQL results directly to C# objects.
```csharp
// It really is this simple
public async Task<IEnumerable<Experience>> GetByPortfolioAsync(int portfolioId)
{
using var db = new SqlConnection(_connectionString);
return await db.QueryAsync<Experience>(
"sp_GetExperiencesByPortfolio",
new { PortfolioId = portfolioId },
commandType: CommandType.StoredProcedure
);
}
```
No DbContext. No configuration. Just SQL and results.
## Performance Difference — Real Numbers
For a simple SELECT of 20 records:
- **Entity Framework Core:** ~45ms average
- **Dapper:** ~8ms average
That's nearly 5x faster for the same operation.
## Where Entity Framework Still Wins
I'm not anti-EF. It genuinely shines when:
- You have complex domain models with many relationships
- You need database migrations built into your workflow
- Your team isn't comfortable writing raw SQL
- Rapid prototyping matters more than performance
## My Current Approach
Use **Dapper** for data retrieval (SELECT operations) and **EF** for complex write operations when needed. They can coexist in the same project.
## Conclusion
Dapper made me a better developer because it forced me to actually understand my SQL. If you're building something where performance matters and you're comfortable with SQL — give Dapper a serious look. You won't go back.