NpgsqlCdc 0.0.3-preview

This is a prerelease version of NpgsqlCdc.
dotnet add package NpgsqlCdc --version 0.0.3-preview
                    
NuGet\Install-Package NpgsqlCdc -Version 0.0.3-preview
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NpgsqlCdc" Version="0.0.3-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NpgsqlCdc" Version="0.0.3-preview" />
                    
Directory.Packages.props
<PackageReference Include="NpgsqlCdc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NpgsqlCdc --version 0.0.3-preview
                    
#r "nuget: NpgsqlCdc, 0.0.3-preview"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NpgsqlCdc@0.0.3-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NpgsqlCdc&version=0.0.3-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NpgsqlCdc&version=0.0.3-preview&prerelease
                    
Install as a Cake Tool

NpgsqlCdc

NpgsqlCdc is a thin PostgreSQL logical replication CDC library for .NET.

Package ID:

  • NpgsqlCdc

Primary namespace:

  • NpgsqlCdc

The goal is to stay close to projects like MySqlCdc:

  • one package
  • one database
  • low-level access to the replication stream
  • no required ASP.NET Core integration
  • no required checkpoint persistence

Minimal usage

using NpgsqlCdc;

var options = new NpgsqlCdcOptions
{
    ConnectionString = "Host=localhost;Database=postgres;Username=postgres;Password=postgres",
    SlotName = "npgsqlcdc_slot",
    CreateSlotIfNotExists = true
};

options.AddPublication("npgsqlcdc_publication");

var client = new NpgsqlCdcClient(options);

await foreach (var @event in client.Replicate())
{
    Console.WriteLine($"{@event.Kind} @ {@event.WalEnd}");
}

NpgsqlCdcClient tracks a safe resume LSN in memory. After successful processing you can read it from client.State.ResumeLsn and persist it anywhere you want.

var checkpoint = client.State.ResumeLsn;

var resumedClient = new NpgsqlCdcClient(options);
resumedClient.SetResumeLsn(checkpoint);

What the library includes

  • NpgsqlCdcClient for streaming pgoutput
  • NpgsqlCdcOptions for replication setup
  • NpgsqlReplicationEvent models for relation, insert, update, delete, truncate, begin, and commit
  • NpgsqlTransaction / ReplicateTransactions() if you prefer committed transaction batches
  • optional helpers for publication setup, replica identity, and slot flush LSN

What the library does not require

  • ASP.NET Core
  • hosted services
  • Redis
  • PostgreSQL cache tables
  • a built-in sink abstraction

Checkpoint persistence is application-owned. The library keeps a safe resume LSN in memory through client.State.ResumeLsn, and your application decides whether to persist it in a file, a database, Redis, or not at all.

Notes

  • The library is focused on row-level PostgreSQL CDC through logical replication and pgoutput.
  • Supported data-change events are INSERT, UPDATE, DELETE, and TRUNCATE.
  • Transaction boundary events and relation metadata are exposed so consumers can group changes and interpret row payloads.
  • DDL CDC is intentionally out of scope. CREATE TABLE, ALTER TABLE, DROP TABLE, and other DDL statements are not emitted as DDL events by this library.
  • PostgreSQL UPDATE and DELETE payloads depend on REPLICA IDENTITY.
  • If you need the full old row image for updates or deletes, configure the table with REPLICA IDENTITY FULL.
  • During an open transaction, resume checkpoint stays at the transaction start to reduce partial-loss risk.
  • Checkpoint persistence is not built in. Persist client.State.ResumeLsn in your application if you need durable resume.

Samples

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.3-preview 60 5/29/2026
0.0.2-preview 53 5/28/2026
0.0.1-preview 60 5/28/2026