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

Thinking about moving off an expensive database?

Proving the provider switch on one small slice first is a cheap way to find out whether it is possible before committing. I can help you assess that for your own system. Get in touch.

View on GitHub