โ† Back to Portfolio.NET ยท EF Core ยท DB Portability

MultipleDbProviderDemo

A focused proof-of-concept: one EF Core codebase, switchable between SQL Server and PostgreSQL by config alone โ€” built to prove the pattern before committing to it in SaasDemo.

Problem

Before building SaasDemo's full multi-tenant system, I needed to know one thing first: can a single EF Core codebase actually run against either SQL Server or PostgreSQL without forking the code? Same driver as SaasDemo โ€” SQL Server licensing costs add up, and having a cheaper provider available for clients mattered.

Architecture

A single Domain and Infrastructure project, with a separate EF Core migration project per provider โ€” MultipleDbProvider.Infrastructure.SqlServerMigrations and .PostGreMigrations. The active provider is one config value in appsettings.json; switching providers means changing that value and running the matching migration project, nothing else.

Scope, deliberately

This one's kept small on purpose โ€” a single Products API, no multi-tenancy, no onion-architecture layering. The only thing worth proving here was the provider switch itself, cheaply, before building anything more complex on top of it.

Technology

.NET, C#, EF Core, SQL Server, PostgreSQL

View on GitHub โ†’