Originally published at SQL & Cloud Lab .
This post was drafted with AI assistance.
Dapper and Entity Framework Core are the two most popular ways to talk to SQL Server from .NET. Debates about them often turn into speed contests, but the better question is: how much do you want to write SQL yourself, and how much do you want the framework to do for you?
Dapper in one minute
Dapper is a "micro-ORM": a small library of extension methods on IDbConnection . You write the SQL; Dapper runs it and maps the results to your objects.
using var conn = new SqlConnection ( connectionString );
var employees = await conn . QueryAsync < Employee > ( @ "SELECT EmployeeId, FullName, DepartmentId FROM dbo.Employee WHERE DepartmentId = @DeptId AND IsActive = 1" , new { DeptId = deptId });
Enter fullscreen mode
Exit fullscreen mode
Parameters are passed as an anonymous object, so queries stay safe from SQL injection.
EF Core in one minute
EF Core is a full ORM.…