RepoDb.SqlServer.BulkOperations
1.17.0-alpha1
Prefix Reserved
dotnet add package RepoDb.SqlServer.BulkOperations --version 1.17.0-alpha1
NuGet\Install-Package RepoDb.SqlServer.BulkOperations -Version 1.17.0-alpha1
<PackageReference Include="RepoDb.SqlServer.BulkOperations" Version="1.17.0-alpha1" />
<PackageVersion Include="RepoDb.SqlServer.BulkOperations" Version="1.17.0-alpha1" />
<PackageReference Include="RepoDb.SqlServer.BulkOperations" />
paket add RepoDb.SqlServer.BulkOperations --version 1.17.0-alpha1
#r "nuget: RepoDb.SqlServer.BulkOperations, 1.17.0-alpha1"
#:package RepoDb.SqlServer.BulkOperations@1.17.0-alpha1
#addin nuget:?package=RepoDb.SqlServer.BulkOperations&version=1.17.0-alpha1&prerelease
#tool nuget:?package=RepoDb.SqlServer.BulkOperations&version=1.17.0-alpha1&prerelease
<div align="center"> <a href="https://repodb.net/tutorial/get-started-sqlserver/"><image src="SQLServer.png" style="width:256px;" /></a> <br/> <span style="font-size:28px;font-weight:bold;"><a href="https://repodb.net/tutorial/get-started-sqlserver/"><strong>RepoDb.SqlServer.BulkOperations</strong></a></span> <br/> <span style="font-size:16px;">A high-performance data productivity platform for bulk operations on SQL Server in .NET.</span> </div>
<br/>
RepoDb.SqlServer.BulkOperations
A high-performant extension library of RepoDB that does bulk operations towards a SQL Server database. It uses the native SqlBulkCopy class to load the data into the database.
Important Pages
- GitHub Home — core library and source code.
- Website — full documentation, API reference, and blog.
Core Features
Community
- GitHub Issues — bug reports and feature requests.
- Microsoft Teams — live Q&A.
- GitHub Discussions — ask questions and share ideas.
- X / Twitter — news and updates.
License
Apache-2.0 — Copyright © 2020 Michael Camara Pendon
Installation
Install-Package RepoDb.SqlServer.BulkOperations
Then initialize the bootstrapper once at application startup:
GlobalConfiguration
.Setup()
.UseSqlServer();
Async Methods
Every synchronous operation has a corresponding Async overload.
BulkInsert
Inserts a list of entities into the database in bulk. Returns the number of inserted rows.
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var insertedRows = connection.BulkInsert<Customer>(customers);
}
Or via table-name:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var insertedRows = connection.BulkInsert("Customer", customers);
}
Or via a DataTable:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var insertedRows = connection.BulkInsert("Customer", table);
}
Returning generated identities:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers(); // Id not set
connection.BulkInsert<Customer>(customers, identityBehavior: SqlServerBulkImportIdentityBehavior.ReturnIdentity);
// customers[i].Id now holds the generated identity for each row
}
BulkMerge
Upserts a list of entities in bulk — inserts new rows and updates existing ones based on the defined qualifiers. Returns the number of affected rows.
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var mergedRows = connection.BulkMerge<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var mergedRows = connection.BulkMerge<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via table-name with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var mergedRows = connection.BulkMerge("Customer", customers, qualifiers: Field.From("LastName", "DateOfBirth"));
}
Or via a DataTable:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var mergedRows = connection.BulkMerge("Customer", table);
}
BulkUpdate
Updates existing rows in the database in bulk, matched by the defined qualifiers. Returns the number of updated rows.
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var rows = connection.BulkUpdate<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via a DataTable:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var rows = connection.BulkUpdate("Customer", table);
}
BulkDelete
Deletes existing rows from the database in bulk, matched by the defined qualifiers. Returns the number of deleted rows.
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var deletedRows = connection.BulkDelete<Customer>(customers);
}
Or with qualifiers:
using (var connection = new SqlConnection(ConnectionString))
{
var customers = GetCustomers();
var deletedRows = connection.BulkDelete<Customer>(customers, qualifiers: e => new { e.LastName, e.DateOfBirth });
}
Or via a DataTable:
using (var connection = new SqlConnection(ConnectionString))
{
var table = GetCustomersAsDataTable();
var deletedRows = connection.BulkDelete("Customer", table);
}
BulkDeleteByKey
Deletes existing rows from the database in bulk, matched by their primary (or identity) key value alone — no entities or DataTable involved, just the list of key values to remove. Returns the number of deleted rows.
using (var connection = new SqlConnection(ConnectionString))
{
var primaryKeys = new [] { 10045, 10046, 10047 };
var deletedRows = connection.BulkDeleteByKey("Customer", primaryKeys);
}
Column Mappings Behavior
When no mappings are passed to BulkInsert, BulkMerge, BulkUpdate, or BulkDelete (or their async variants), the columns of the source (entities, DataTable, or DbDataReader) are aligned with the columns of the destination table based on the BulkColumnMappingsBehavior setting:
| Value | Column names must match | Column order must match | Destination columns missing from the source | Source columns missing from the destination |
|---|---|---|---|---|
Automatic (default) |
Only the matching ones | No | Bypassed | Ignored |
Strict |
Yes | Yes | Throws | Throws |
StrictBypass |
Yes | No | Bypassed | Throws |
Automatic is the default and is the behavior of the earlier versions. SqlServerBulkOperationsDbSetting inherits SqlServerDbSetting, and UseSqlServer(...) registers it as the setting of the SqlConnection in place of the default one. Strict and StrictBypass throw a SqlServerBulkColumnMappingsException (naming the offending columns) before any data is written.
GlobalConfiguration
.Setup()
.UseSqlServer(new SqlServerBulkOperationsDbSetting
{
BulkColumnMappingsBehavior = SqlServerBulkColumnMappingsBehavior.StrictBypass
});
For example, with a Customer table that has the Id, Name, Email, and CreatedDateUtc columns, and a DataTable source with the Email, Name, and Nickname columns:
Strictthrows, because the order differs,Id/CreatedDateUtcare missing, andNicknamedoes not exist in the destination.StrictBypassthrows, becauseNicknamedoes not exist in the destination.AutomaticinsertsNameandEmail, and ignoresNickname.
try
{
await connection.BulkInsertAsync("[dbo].[Customer]", table);
}
catch (SqlServerBulkColumnMappingsException ex)
{
// e.g. "... Source column(s) that do not exist on the destination table: 'Nickname'."
logger.LogError(ex, "Bulk insert rejected due to column misalignment.");
throw;
}
Explicitly passed mappings always take precedence: the setting is not applied to them. BulkDeleteByKey is not affected, as its source is a list of key values rather than a set of columns.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.11)
- RepoDb (>= 1.17.0-alpha3)
- RepoDb.SqlServer (>= 1.17.0-alpha1)
-
net10.0
- RepoDb (>= 1.17.0-alpha3)
- RepoDb.SqlServer (>= 1.17.0-alpha1)
-
net8.0
- RepoDb (>= 1.17.0-alpha3)
- RepoDb.SqlServer (>= 1.17.0-alpha1)
-
net9.0
- RepoDb (>= 1.17.0-alpha3)
- RepoDb.SqlServer (>= 1.17.0-alpha1)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on RepoDb.SqlServer.BulkOperations:
| Package | Downloads |
|---|---|
|
2doit.NopCommerce.Services
2doit NopCommerce API Services/Libraries |
|
|
NGen
Package Description |
|
|
CafeLib.Data.Sources.SqlServer
SQL Server data source packge |
|
|
Gasolutions.Core.GenericRepository.RepoDB
Interface and Implementation for a generic repository using RepoDB. |
|
|
Fx.Data.SQL
Package Description |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on RepoDb.SqlServer.BulkOperations:
| Repository | Stars |
|---|---|
|
TortugaResearch/DotNet-ORM-Cookbook
This repository is meant to show how to perform common tasks using C# with variety of ORMs.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.17.0-alpha1 | 78 | 10/2/2026 |
| 1.16.2 | 529 | 9/25/2026 |
| 1.16.1 | 104 | 9/25/2026 |
| 1.16.0 | 1,298 | 9/9/2026 |
| 1.16.0-beta1 | 147 | 8/15/2026 |
| 1.16.0-alpha2 | 115 | 8/6/2026 |
| 1.16.0-alpha1 | 124 | 8/5/2026 |
| 1.15.0 | 7,648 | 7/18/2026 |
| 1.15.0-telemetry | 116 | 7/18/2026 |
| 1.14.0 | 4,811 | 6/28/2026 |
| 1.13.2-alpha1 | 1,924 | 2/26/2024 |
| 1.13.1 | 376,435 | 3/16/2023 |
| 1.13.0 | 17,728 | 11/2/2022 |
| 1.13.0-beta1 | 840 | 10/25/2022 |
| 1.13.0-alpha3 | 825 | 10/24/2022 |
| 1.13.0-alpha2 | 813 | 10/6/2022 |
| 1.13.0-alpha1 | 862 | 9/17/2022 |
| 1.1.6 | 57,962 | 2/18/2022 |
| 1.1.6-beta2 | 1,539 | 12/13/2021 |