
When building enterprise-grade applications in ASP.NET Core, choosing the right database provider is not just a technical decision — it directly impacts performance, scalability, maintainability, and cloud strategy.
In this article, we'll explore the different types of database providers available in ASP.NET Core, how they work internally, how to choose the right database provider, and when to use each — with real-world coding examples.
1. Understanding Database Providers in ASP.NET Core
ASP.NET Core itself does not talk directly to a database. Instead, it relies on:
ADO.NET providers
Entity Framework Core database providers
Micro-ORM providers (like Dapper)
NoSQL SDK providers
In-memory providers for testing
The abstraction layer allows you to switch providers without rewriting your business logic.
The most common abstraction used today is Entity Framework Core (EF Core).
2. Entity Framework Core Relational Providers
EF Core supports multiple relational database engines through pluggable providers .
2.1 SQL Server Provider
Package
Microsoft.EntityFrameworkCore.SqlServer
Best for
Enterprise systems
Azure-hosted apps
Microsoft ecosystem environments
Setup Example
Install package
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
Register in Program.cs
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(
builder.Configuration.GetConnectionString("DefaultConnection")));
Connection string ( appsettings.json )
"ConnectionStrings": {
"DefaultConnection": "Server=.;Database=AppDb;Trusted_Connection=True;"
}
Production scenario
Banking systems
ERP systems
Applications using SQL Server Always On
2.2 PostgreSQL Provider
Package
Npgsql.EntityFrameworkCore.PostgreSQL
Best for
Linux deployments
Cloud-native systems
Cost-optimized production environments
Setup Example
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(
builder.Configuration.GetConnectionString("PostgresConnection")));
Connection string
"PostgresConnection": "Host=localhost;Database=AppDb;Username=postgres;Password=pass"
Real-world use case
SaaS multi-tenant platforms
Kubernetes deployments
2.3 MySQL / MariaDB Provider
Package
Pomelo.EntityFrameworkCore.MySql
Setup
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseMySql(
builder.Configuration.GetConnectionString("MySqlConnection"),
ServerVersion.AutoDetect(
builder.Configuration.GetConnectionString("MySqlConnection"))));
Best for
Hosting providers
PHP-to-.NET migration projects
2.4 SQLite Provider
Package
Microsoft.EntityFrameworkCore.Sqlite
Use cases
Desktop apps
Mobile apps
Lightweight internal tools
Example
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlite("Data Source=app.db"));
Common in
Proof of Concepts
Edge deployments
3. In-Memory Provider (Testing)
Package
Microsoft.EntityFrameworkCore.InMemory
Important: Not a real relational database.
Join the conversation! Your thoughts help the community grow.