NSchema 2.1.0
See the version list below for details.
dotnet add package NSchema --version 2.1.0
NuGet\Install-Package NSchema -Version 2.1.0
<PackageReference Include="NSchema" Version="2.1.0" />
<PackageVersion Include="NSchema" Version="2.1.0" />
<PackageReference Include="NSchema" />
paket add NSchema --version 2.1.0
#r "nuget: NSchema, 2.1.0"
#:package NSchema@2.1.0
#addin nuget:?package=NSchema&version=2.1.0
#tool nuget:?package=NSchema&version=2.1.0
NSchema is a declarative database schema migration library for .NET.
You describe the schema you want in C#. NSchema compares it against the current state of your database, then runs the SQL to bring it in line.
Designed to be familiar to .NET devs, with extensibility and safety features to support many different workflows.
Getting started
Install the core package and a database provider:
dotnet add package NSchema
dotnet add package NSchema.Postgres # or another provider
Declare a schema by subclassing AbstractSchemaProvider:
using NSchema.Schema;
using NSchema.Schema.Fluent;
public class AppSchema : AbstractSchemaProvider
{
public AppSchema()
{
Schema("app", s => s
.Table("users", t => t
.Column("id", SqlType.Text, c => c.PrimaryKey("users_pkey"))
.Column("email", SqlType.Text, c => c.NotNull())
.Column("name", SqlType.Text, c => c.NotNull())
.Index("uc_users_email", ["email"], i => i.Unique())
)
);
}
}
Wire up and run the application:
using NSchema;
using NSchema.Migration;
using NSchema.Postgres;
var builder = NSchemaApplication.CreateBuilder(args);
builder
.AddSchema<AppSchema>()
.UsePostgres(connectionString)
.WithDestructiveActionPolicy(DestructiveActionPolicy.Warn);
var app = builder.Build();
await app.Apply();
On startup, NSchema introspects the database, compares it with your desired schema, and applies the resulting plan.
A run performs one of three operations:
Plan(default) computes the plan and renders it without touching the database.Applycomputes the plan and applies it.Refreshcaptures the current live schema to the state store without planning or applying.
Call app.Plan() / app.Apply() / app.Refresh() explicitly, or configure the default via RunOperation(...) and use RunAsync(). See Configuration for details.
Documentation
- Configuration. Hosting, operations, destructive-action policy, scoping, registering schemas, scripts, and policies.
- Defining schemas. The full fluent reference for schemas, tables, columns, foreign keys, and indexes.
- Concepts. The domain model, the pipeline, and how the pieces fit together.
- Extension points. Every interface you can swap or extend, and how to register it.
- Samples. Complete sample applications and reference implementations.
- Roadmap. Planned features and improvements.
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
- Microsoft.Extensions.Configuration (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.8)
- Microsoft.Extensions.Hosting (>= 10.0.8)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Logging.Console (>= 10.0.8)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on NSchema:
| Package | Downloads |
|---|---|
|
NSchema.Postgres
PostgreSQL provider for NSchema |
|
|
NSchema.Aws
AWS provider for NSchema |
|
|
NSchema.Yaml
YAML provider for NSchema |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.1 | 0 | 6/3/2026 |
| 2.2.0-alpha2 | 43 | 6/2/2026 |
| 2.2.0-alpha.1 | 40 | 6/2/2026 |
| 2.1.0 | 64 | 6/1/2026 |
| 2.0.1 | 59 | 6/1/2026 |
| 2.0.0 | 72 | 6/1/2026 |
| 2.0.0-alpha.7 | 55 | 6/1/2026 |
| 2.0.0-alpha.6 | 68 | 5/31/2026 |
| 2.0.0-alpha.5 | 74 | 5/31/2026 |
| 2.0.0-alpha.4 | 65 | 5/30/2026 |
| 2.0.0-alpha.3 | 60 | 5/30/2026 |
| 2.0.0-alpha.2 | 64 | 5/30/2026 |
| 2.0.0-alpha.1 | 45 | 5/30/2026 |
| 1.0.1 | 100 | 5/27/2026 |
| 1.0.0 | 129 | 5/27/2026 |
| 1.0.0-rc.3 | 88 | 5/27/2026 |
| 1.0.0-rc.2 | 46 | 5/27/2026 |
| 1.0.0-rc.1 | 47 | 5/27/2026 |
