PgBulk.EFCore 2.0.2

dotnet add package PgBulk.EFCore --version 2.0.2
                    
NuGet\Install-Package PgBulk.EFCore -Version 2.0.2
                    
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="PgBulk.EFCore" Version="2.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PgBulk.EFCore" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="PgBulk.EFCore" />
                    
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 PgBulk.EFCore --version 2.0.2
                    
#r "nuget: PgBulk.EFCore, 2.0.2"
                    
#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 PgBulk.EFCore@2.0.2
                    
#: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=PgBulk.EFCore&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=PgBulk.EFCore&version=2.0.2
                    
Install as a Cake Tool

PgBulk

High-performance bulk operations for PostgreSQL using Npgsql binary import (COPY ... FROM STDIN BINARY).

Features

  • Bulk Insert — fast binary import of large datasets
  • Bulk Merge (Upsert) — insert or update using primary key or custom key columns
  • Bulk Sync — replace table contents (delete + insert) with optional WHERE clause
  • EF Core integration — extension methods on DbContext with automatic table/column mapping
  • Manual mapping — use without EF Core by defining table mappings explicitly
  • CancellationToken support throughout all async operations
  • Configurable timeoutCommandTimeout property (default: 0 = infinite, appropriate for bulk workloads)
  • Multi-target: net8.0, net9.0, net10.0

Installation

dotnet add package PgBulk.EFCore

Or for usage without EF Core:

dotnet add package PgBulk

Quick Start (EF Core)

using PgBulk.EFCore;

// Bulk insert
await dbContext.BulkInsertAsync(entities);

// Bulk upsert (merge) — matches on primary key
await dbContext.BulkMergeAsync(entities);

// Bulk sync — deletes rows not in the collection, then inserts all
await dbContext.BulkSyncAsync(entities);

// With options
await dbContext.BulkInsertAsync(entities,
    timeoutOverride: 120,
    onConflictIgnore: true,
    cancellationToken: ct);

Quick Start (Manual Mapping)

var provider = new ManualTableInformationProvider()
    .AddTableMapping<MyEntity>("my_table", c => c.Automap());

var bulk = new ManualBulkOperator(connectionString, provider);
await bulk.InsertAsync(entities, onConflictIgnore: false);

Custom Merge Keys

By default, merge uses the primary key. To merge on different columns:

var keyProvider = new EntityManualTableKeyProvider<MyEntity>();
await keyProvider.AddKeyColumn(e => e.ExternalId, dbContext);

await dbContext.BulkMergeAsync(entities, tableKeyProvider: keyProvider);

Timeout Configuration

The default CommandTimeout is 0 (infinite), which is appropriate for bulk operations on large datasets. Override per-call or per-operator:

// Per-call via extension method
await dbContext.BulkInsertAsync(entities, timeoutOverride: 300);

// Per-operator instance
var op = dbContext.GetBulkOperator(timeoutOverride: 300);
// or
op.CommandTimeout = 300;

License

MIT

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 is compatible.  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 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. 
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
2.0.2 109 3/11/2026
2.0.1 193 2/20/2026
2.0.0 371 2/19/2026
1.2.2 2,010 12/14/2023
1.2.0 234 12/14/2023
1.1.17 271 11/6/2023
1.1.16 2,774 11/6/2023
1.1.15 260 10/16/2023
1.1.14 233 10/16/2023
1.1.13 248 10/9/2023
1.1.12 229 10/6/2023
1.1.11 224 10/4/2023
1.1.10 433 10/2/2023
1.1.9 222 10/2/2023
1.1.8 258 9/27/2023
1.1.7 209 9/25/2023
1.1.6 223 9/22/2023
1.1.5 203 9/22/2023
1.1.4 214 9/21/2023
1.1.3 225 9/20/2023
Loading failed