LLS.EFBulkExtensions 1.2.0

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

LLS.EFBulkExtensions

[English] | Português

High-performance extensions for EF Core 9 bulk operations: insert, update and delete with large volumes, batch processing, SQL Server and PostgreSQL support, type conversions, owned types, and optional returning of generated IDs.

Features

  • Bulk insert, update and delete via DbContext extension methods
  • Batch processing (BatchSize) and timeout control
  • Support for SQL Server (SqlBulkCopy/MERGE) and PostgreSQL (binary COPY)
  • Optional returning of generated IDs on inserts
  • Handling properties with conversions (e.g., EnumToString) and owned types
  • Optional internal transaction and extra configuration via model annotations

Compatibility and Dependencies

  • .NET: net9.0
  • EF Core 9.0 (Relational)
  • Providers:

Installation

  • Local project: add a ProjectReference to src/LLS.EFBulkExtensions.
  • NuGet (if published): reference the LLS.EFBulkExtensions package and ensure:
    • SQL Server: Microsoft.EntityFrameworkCore.SqlServer
    • PostgreSQL: Npgsql.EntityFrameworkCore.PostgreSQL

Quick Start

Import the extensions and call the methods from your DbContext:

using LLS.EFBulkExtensions.Extensions;
using LLS.EFBulkExtensions.Options;

SQL Server:

var options = new DbContextOptionsBuilder<AppDbContext>()
    .UseSqlServer("<your-connection-string>")
    .Options;

PostgreSQL:

var options = new DbContextOptionsBuilder<AppDbContext>()
    .UseNpgsql("<your-connection-string>")
    .Options;

Insert:

await context.BulkInsertAsync(entities, new BulkInsertOptions {
    ReturnGeneratedIds = false,
    BatchSize = 10_000,
    TimeoutSeconds = 120,
    PreserveIdentity = false,
    UseInternalTransaction = false,
    KeepNulls = false,
    UseAppLock = false
});

Update:

await context.BulkUpdateAsync(entitiesToUpdate, new BulkUpdateOptions {
    BatchSize = 10_000,
    TimeoutSeconds = 120,
    UseInternalTransaction = false
});

Delete:

await context.BulkDeleteAsync(entitiesToDelete, new BulkDeleteOptions {
    BatchSize = 10_000,
    TimeoutSeconds = 120,
    UseInternalTransaction = false
});

Options

  • BulkInsertOptions: file
    • ReturnGeneratedIds, BatchSize, TimeoutSeconds, PreserveIdentity, UseInternalTransaction, KeepNulls, UseAppLock
  • BulkUpdateOptions: file
    • BatchSize, TimeoutSeconds, UseInternalTransaction
  • BulkDeleteOptions: file
    • BatchSize, TimeoutSeconds, UseInternalTransaction

You can also configure annotations directly on the model for insert:

builder.Property(p => p.Id).ValueGeneratedOnAdd(ReturnGeneratedIds: true, BatchSize: 10000);

Extension: SequenceModelExtensions.

Database Support

How It Works

  • Insert:
    • SQL Server: uses SqlBulkCopy for staging and MERGE with OUTPUT when needed to return IDs.
    • PostgreSQL: uses binary COPY; when requested, inserts into a temporary table and returns IDs via INSERT ... RETURNING.
  • Update: creates a temporary table, bulk loads into temp and applies UPDATE with JOIN on PK, ignoring ValueGenerated columns.
  • Delete: creates a temporary table and applies DELETE with JOIN on PK. Data construction: DataTableBuilder maps properties, types, conversions (includes EnumToString) and owned types.

Full Examples

Requirements

  • EF Core 9 with correct entity mapping (table, schema, PK)
  • To return IDs on inserts, use PK with ValueGeneratedOnAdd and optionally annotate ReturnGeneratedIds via model

APIs

Notes

  • BatchSize and Timeout configurable via options and annotations
  • Optional internal transaction
  • Support for PreserveIdentity and KeepNulls on insert
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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
1.2.0 148 2/2/2026
1.1.0 129 2/2/2026
1.0.1 124 2/2/2026