NSchema.Postgres
2.0.0
See the version list below for details.
dotnet add package NSchema.Postgres --version 2.0.0
NuGet\Install-Package NSchema.Postgres -Version 2.0.0
<PackageReference Include="NSchema.Postgres" Version="2.0.0" />
<PackageVersion Include="NSchema.Postgres" Version="2.0.0" />
<PackageReference Include="NSchema.Postgres" />
paket add NSchema.Postgres --version 2.0.0
#r "nuget: NSchema.Postgres, 2.0.0"
#:package NSchema.Postgres@2.0.0
#addin nuget:?package=NSchema.Postgres&version=2.0.0
#tool nuget:?package=NSchema.Postgres&version=2.0.0
NSchema.Postgres
PostgreSQL provider for NSchema, the declarative database schema migration library for .NET.
This package plugs PostgreSQL-specific implementations of NSchema's ISchemaProvider (live-database introspection) and ISqlPlanner (DDL generation) into your application, and contributes Postgres-only SqlType helpers.
Getting started
Install the core package and this provider:
dotnet add package NSchema
dotnet add package NSchema.Postgres
Register Postgres against an NSchemaApplicationBuilder:
using NSchema;
using NSchema.Postgres;
var builder = NSchemaApplication.CreateBuilder(args);
builder
.AddSchemasFromAssemblyContaining<Program>()
.UseCurrentSchemaPostgres(connectionString);
var app = builder.Build();
await app.Apply();
On startup NSchema introspects the database through this provider, diffs it against your declared schema, and applies the resulting plan.
Configuration
UseCurrentSchemaPostgres has four overloads. The three connection-aware overloads register an NpgsqlDataSource for you (via AddNpgsqlDataSource) and wire up the current schema provider and SQL planner; the no-arg overload assumes you've already registered an NpgsqlDataSource yourself.
// 1. Connection string.
builder.UseCurrentSchemaPostgres("Host=localhost;Database=app;Username=postgres;Password=postgres");
// 2. Configure the data source builder directly.
builder.UseCurrentSchemaPostgres(b => b
.EnableDynamicJson()
.UseLoggerFactory(loggerFactory)
);
// 3. As above, with access to the IServiceProvider.
builder.UseCurrentSchemaPostgres((sp, b) => b.UseLoggerFactory(sp.GetRequiredService<ILoggerFactory>()));
// 4. Bring your own data source.
builder.Services.AddNpgsqlDataSource(connectionString);
builder.UseCurrentSchemaPostgres();
Postgres-specific types
SqlTypePostgresExtensions adds Postgres-only members to SqlType:
| Member | Postgres type | Notes |
|---|---|---|
SqlType.Citext |
citext |
Case-insensitive text. Requires the citext extension. |
SqlType.Jsonb |
jsonb |
Binary JSON. |
users.Column("email", SqlType.Citext).NotNull();
users.Column("metadata", SqlType.Jsonb);
citext requires CREATE EXTENSION citext; in the target database — NSchema.Postgres does not create extensions for you.
Supported schema objects
The introspector reads, and the planner emits DDL for:
- Schemas (including comments and
GRANTs on the schema itself) - Tables (including comments and table-level
GRANTs) - Columns (types, nullability, defaults, comments)
- Primary keys
- Foreign keys
- Indexes, including unique indexes and index comments
Requirements
- .NET 10
- PostgreSQL (tested against
postgres:17-alpinevia Testcontainers)
License
See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Npgsql (>= 10.0.3)
- Npgsql.DependencyInjection (>= 10.0.3)
- NSchema (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.1 | 0 | 6/4/2026 |
| 2.0.0 | 85 | 6/1/2026 |
| 2.0.0-alpha.2 | 65 | 5/31/2026 |
| 2.0.0-alpha.1 | 68 | 5/30/2026 |
| 1.0.0 | 109 | 5/27/2026 |
| 1.0.0-rc.1 | 92 | 5/27/2026 |