# PostgreSQL vs SQL Server for .NET Developers

> SQL Server used to be the default database for .NET, but the .NET-on-Postgres stack is now mainstream. Here is a feature-by-feature comparison of what changes in your code, operations, and costs.

Published: 2026-11-26. Author: Milan Jovanović.

Canonical: https://milanjovanovic.tech/blog/postgresql-vs-sql-server-dotnet

For two decades, .NET shops picked SQL Server by default.
The license was already paid for, the tooling was great, and everything Microsoft published assumed it.

That default no longer holds.
Microsoft's own eShop reference app runs on PostgreSQL, and Aspire ships a PostgreSQL hosting integration, even though the `dotnet new` templates with Individual auth still default to SQLite (or SQL Server LocalDB with `--use-local-db`).
This comparison covers what changes in your code, operations, and costs when you move.

## The Bill Comes First

Cost is usually the main driver.

- **SQL Server Standard** is licensed per core in two-core packs. Microsoft's estimated retail price for SQL Server 2025 is $3,945 per pack for a perpetual license (Software Assurance is extra), or $1,418 per pack per year as a subscription. A modest 8-core production server is a five-figure line item, and that's before your standby replica.
- **SQL Server in the cloud** carries the license inside the hourly rate. An Azure SQL or RDS SQL Server instance costs a multiple of the same-sized PostgreSQL instance.
- **PostgreSQL** is free to self-host, and managed Postgres (RDS, Azure Database for PostgreSQL, Cloud SQL, Neon, Supabase) costs less than managed SQL Server on the same hardware, because no license is built into the rate. The exception is the smallest tier: Azure SQL Database Basic costs less per month than the smallest Azure Database for PostgreSQL flexible server.

There are legitimate reasons to pay for SQL Server.
But if you're paying it out of inertia, that's a per-core license purchase (plus Software Assurance) or a subscription bill every year, for features you may not use.

Express Edition is free, but SQL Server 2025 limits it to 50 GB per database, 4 cores, and about 1.4 GB of buffer pool memory, which rules it out for most production workloads.

## Provider and Ecosystem: A Tie

The fear used to be that Postgres was a second-class citizen in .NET.
That hasn't been true for years.

**Npgsql** is one of the best ADO.NET providers, and `Npgsql.EntityFrameworkCore.PostgreSQL` tracks EF Core releases closely, often shipping provider support for new EF features before other third-party providers.

```bash
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL
```

```csharp
builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseNpgsql(builder.Configuration.GetConnectionString("Database")));
```

Dapper, ADO.NET, health checks, OpenTelemetry instrumentation, Testcontainers, Aspire integrations: everything you use with SQL Server exists for Postgres, at the same quality.
If you're starting fresh, I have a full walkthrough in [**EF Core with PostgreSQL: getting started**](https://milanjovanovic.tech/blog/ef-core-postgresql-getting-started).

## What Changes in Your Code

Switching providers takes more than a connection string change, and the differences show up in specific, predictable places.

**UTC timestamps are enforced.**
Npgsql maps `DateTime` to `timestamptz` and throws if you write a `DateTime` whose `Kind` isn't `Utc`.
This is the most common migration error, and the exception keeps ambiguous timestamps out of the database.
I broke down the fix in [**the EF Core PostgreSQL DateTime UTC error**](https://milanjovanovic.tech/blog/ef-core-postgresql-datetime-utc-error).

**Concurrency tokens work differently.**
SQL Server uses a `rowversion` column.
Postgres has a built-in system column, `xmin`, that changes on every update, so you don't add a column at all:

```csharp
modelBuilder.Entity<Order>()
    .Property<uint>("xmin")
    .IsRowVersion();
```

The mechanics are in [**EF Core optimistic concurrency with xmin**](https://milanjovanovic.tech/blog/ef-core-postgresql-xmin-concurrency).

**Identifier casing.**
Postgres folds unquoted identifiers to lowercase, and the usual convention is `snake_case`.
The `EFCore.NamingConventions` package handles it in one line:

```csharp
options.UseNpgsql(connectionString).UseSnakeCaseNamingConvention();
```

**SQL dialect differences.**
If you have raw SQL, expect to translate: `TOP` becomes `LIMIT`, `GETUTCDATE()` becomes `now()`, `NEWID()` becomes `gen_random_uuid()`, string concatenation with `+` becomes `||`, and `MERGE` exists in both but with different syntax and semantics.
Stored procedures move from T-SQL to PL/pgSQL, which is a real porting effort if you have hundreds of them; I show the Postgres side in [**using stored procedures and functions with EF Core and PostgreSQL**](https://milanjovanovic.tech/blog/using-stored-procedures-and-functions-with-ef-core-and-postgresql).

**Migrations must be regenerated.**
EF Core migrations encode provider-specific SQL, so you delete and re-scaffold them against the new provider rather than reusing them.

## Where PostgreSQL Is Ahead

A few capabilities are stronger or more mature in Postgres, and they change how you design:

- **jsonb.** Real binary JSON with indexing and containment operators, integrated with EF Core's JSON column mapping. SQL Server 2025 added a native `json` type and JSON indexes, while Postgres has had `jsonb` with GIN indexing since version 9.4 (2014).
- **Rich types.** Arrays, ranges, `inet`, composite types, and enums map directly to .NET types through Npgsql. An `int[]` column with a contains query replaces an entire join table in the right situation.
- **Extensions.** `pgvector` turns your database into a vector store for AI features ([**pgvector in .NET**](https://milanjovanovic.tech/blog/getting-started-with-pgvector-in-dotnet-for-simple-vector-search)), PostGIS is the industry-standard geospatial engine, and pg_partman automates partition lifecycle.

Full-text search is not on this list, because SQL Server ships Full-Text Search in every edition too.
The Postgres version is good enough to skip Elasticsearch for many workloads ([**PostgreSQL full-text search with EF Core**](https://milanjovanovic.tech/blog/postgresql-full-text-search-ef-core)), but it's no reason to switch on its own.

## Where SQL Server Still Wins

- **Tooling.** SSMS plus Query Store is still the best "why is this slow" experience. Postgres gives you `pg_stat_statements` and EXPLAIN, which do the job but are rawer.
- **Columnstore indexes.** For heavy analytics inside the operational database, clustered columnstore is excellent. Postgres needs an extension or a separate analytical store for the same job.
- **Enterprise security features.** Always Encrypted, Dynamic Data Masking, and mature Transparent Data Encryption ship in the box. Postgres covers encryption at rest through the platform, which is usually fine but less granular.
- **In-house expertise.** If your team has 15 years of SQL Server operational experience (backups, DMVs, execution plans), that knowledge has real value and Postgres resets part of it.
- **The Microsoft stack.** SSIS, on-premises reporting (SSRS, folded into Power BI Report Server as of SQL Server 2025), and deep Active Directory integration matter in enterprises that already run on them.

One difference that cuts both ways: both databases default to read committed isolation, but SQL Server's default implementation is lock-based (readers and writers block each other unless RCSI is enabled), while Postgres is MVCC throughout.
Workloads that felt deadlock-prone on SQL Server often just work on Postgres, but code that accidentally relied on blocking behavior can surface race conditions you now have to handle explicitly.

## How to Choose

The differences side by side:

| Concern | PostgreSQL | SQL Server |
| --- | --- | --- |
| License | Free to self-host | Standard: $3,945 per two-core pack, or $1,418 per pack per year |
| Managed cloud price | No license in the hourly rate | License included in the hourly rate |
| Concurrency token | xmin system column | rowversion column |
| Read committed | MVCC, readers and writers do not block | Lock-based unless RCSI is enabled |
| JSON | jsonb with GIN indexing since 9.4 | Native json type and JSON indexes in SQL Server 2025 |
| Analytics on operational data | Needs an extension or a separate store | Columnstore indexes |
| Security features | Encryption at rest through the platform | Always Encrypted, Dynamic Data Masking, TDE |
| Tooling | pg_stat_statements and EXPLAIN | SSMS and Query Store |

Rules of thumb for the decision:

- **New project, no constraints**: PostgreSQL. Lower cost, richer type system, and extensions give you options (vectors, geo, partitioning) you don't know you need yet.
- **Existing SQL Server system that works**: stay. A migration is a project, and "save on licensing" alone rarely justifies rewriting hundreds of stored procedures.
- **Heavy analytical queries on operational data**: SQL Server's columnstore is a legitimate reason to pay.
- **AI features on the roadmap**: Postgres with pgvector keeps vector search in the same database as the rest of your data. SQL Server 2025 added a native `vector` type too, but its DiskANN vector index still requires preview features.
- **Regulated enterprise with SQL Server-specific security requirements**: the Enterprise Edition features may be non-negotiable.

If you do migrate, treat it as a real project: regenerate migrations, audit every raw SQL string, fix the UTC DateTime issues, port stored procedures, and run both databases side by side behind an interface until the numbers match.
If the application is embedded, single-node, and mostly single-writer, [**SQLite with EF Core**](https://milanjovanovic.tech/blog/sqlite-dotnet-ef-core) may be a better fit than either server database.

## Summary

The .NET-on-Postgres stack is mainstream.
Npgsql and the EF Core provider are excellent, the dialect differences are finite and well-documented, and PostgreSQL removes a per-core license that costs thousands of dollars per server.

SQL Server still earns its license in specific places: columnstore analytics, enterprise security features, and teams whose operational expertise is already there.

Pick based on those specifics.

## Frequently asked questions

### Is PostgreSQL a good choice for .NET applications?

Yes. The Npgsql ADO.NET and EF Core providers are actively maintained and track EF Core releases closely. Microsoft runs its eShop reference application on PostgreSQL, and Aspire ships a PostgreSQL hosting integration.

### How much does SQL Server cost compared to PostgreSQL?

SQL Server 2025 Standard is licensed per core in two-core packs, at an estimated retail price of $3,945 per pack (about $1,970 per core) for a perpetual license, or $1,418 per pack per year as a subscription. Managed SQL Server also costs more in the cloud, because the license is part of the hourly rate. PostgreSQL is free to self-host, and managed PostgreSQL is consistently the cheaper tier at the same hardware size.

### What changes in EF Core when switching from SQL Server to PostgreSQL?

You swap the provider package, regenerate migrations, and adjust a few behaviors: timestamp columns require UTC DateTime values, identifiers become snake_case by convention if you opt in, and concurrency tokens use the xmin system column instead of rowversion.

### Does PostgreSQL have something like SQL Server Management Studio?

pgAdmin is the closest equivalent, and JetBrains DataGrip, DBeaver, and the database tools in Rider and VS Code cover most workflows. SSMS is still more polished for deep engine administration.
