Rivulet.Sql.SqlServer
1.3.0-beta
This is a prerelease version of Rivulet.Sql.SqlServer.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Rivulet.Sql.SqlServer --version 1.3.0-beta
NuGet\Install-Package Rivulet.Sql.SqlServer -Version 1.3.0-beta
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="Rivulet.Sql.SqlServer" Version="1.3.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rivulet.Sql.SqlServer" Version="1.3.0-beta" />
<PackageReference Include="Rivulet.Sql.SqlServer" />
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 Rivulet.Sql.SqlServer --version 1.3.0-beta
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rivulet.Sql.SqlServer, 1.3.0-beta"
#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 Rivulet.Sql.SqlServer@1.3.0-beta
#: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=Rivulet.Sql.SqlServer&version=1.3.0-beta&prerelease
#tool nuget:?package=Rivulet.Sql.SqlServer&version=1.3.0-beta&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Rivulet.Sql.SqlServer
SQL Server-specific optimizations for Rivulet.Sql including SqlBulkCopy integration for 10-100x faster bulk inserts.
Features
- SqlBulkCopy Integration: Ultra-high performance bulk inserts (50,000+ rows/sec)
- Parallel Bulk Operations: Process multiple batches in parallel
- Automatic Column Mapping: Maps DataTable columns to SQL Server table columns
- Custom Column Mappings: Support for explicit source-to-destination column mappings
- DataReader Support: Bulk insert from IDataReader sources
- Configurable Batching: Control batch size and timeout settings
Installation
dotnet add package Rivulet.Sql.SqlServer
Usage
Basic SqlBulkCopy
using Rivulet.Sql.SqlServer;
var users = GetUsers(); // IEnumerable<User>
await users.BulkInsertUsingSqlBulkCopyAsync(
() => new SqlConnection(connectionString),
"Users",
batch => MapToDataTable(batch), // Convert to DataTable
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 },
batchSize: 5000
);
// Helper method to map objects to DataTable
DataTable MapToDataTable(IEnumerable<User> users)
{
var table = new DataTable();
table.Columns.Add("Id", typeof(int));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Email", typeof(string));
foreach (var user in users)
{
table.Rows.Add(user.Id, user.Name, user.Email);
}
return table;
}
Custom Column Mappings
var columnMappings = new Dictionary<string, string>
{
["UserId"] = "Id",
["FullName"] = "Name",
["EmailAddress"] = "Email"
};
await users.BulkInsertUsingSqlBulkCopyAsync(
() => new SqlConnection(connectionString),
"Users",
batch => MapToDataTable(batch),
columnMappings,
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 4 }
);
DataReader Bulk Insert
var readers = GetDataReaders(); // IEnumerable<IDataReader>
await readers.BulkInsertUsingSqlBulkCopyAsync(
() => new SqlConnection(connectionString),
"Users",
options: new ParallelOptionsRivulet { MaxDegreeOfParallelism = 2 },
batchSize: 10000
);
Advanced Options
await users.BulkInsertUsingSqlBulkCopyAsync(
() => new SqlConnection(connectionString),
"Users",
batch => MapToDataTable(batch),
options: new ParallelOptionsRivulet
{
MaxDegreeOfParallelism = 4,
ErrorMode = ErrorMode.CollectAndContinue
},
bulkCopyOptions: SqlBulkCopyOptions.KeepIdentity | SqlBulkCopyOptions.CheckConstraints,
batchSize: 5000,
bulkCopyTimeout: 60
);
Performance
Comparison: Standard Insert vs SqlBulkCopy
| Method | Rows/sec | Time for 100k rows |
|---|---|---|
| Standard Batched Insert | ~1,000 | ~100 seconds |
| SqlBulkCopy | ~50,000+ | ~2 seconds |
| Performance Gain | 50x faster | 50x faster |
Recommended Settings
- Batch Size: 5,000-10,000 rows per batch
- Max Parallelism: 2-4 for most workloads
- Timeout: 30-60 seconds depending on data size
When to Use
✅ Use Rivulet.Sql.SqlServer when:
- Inserting 1,000+ rows
- Maximum performance is critical
- Using SQL Server exclusively
❌ Use base Rivulet.Sql when:
- Multi-database support needed
- Smaller datasets (<1,000 rows)
- Cross-platform compatibility required
Requirements
- .NET 8.0 or .NET 9.0
- SQL Server 2012 or later
- Microsoft.Data.SqlClient
License
MIT License - see LICENSE file for details
| Product | Versions 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 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.
-
net8.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- Rivulet.Sql (>= 1.3.0-beta)
-
net9.0
- Microsoft.Data.SqlClient (>= 6.1.3)
- Rivulet.Sql (>= 1.3.0-beta)
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.3.0 | 152 | 12/13/2025 |
| 1.3.0-beta | 413 | 12/8/2025 |
| 1.3.0-alpha | 289 | 12/8/2025 |