Prakrishta.Data.Bulk
1.0.0
See the version list below for details.
dotnet add package Prakrishta.Data.Bulk --version 1.0.0
NuGet\Install-Package Prakrishta.Data.Bulk -Version 1.0.0
<PackageReference Include="Prakrishta.Data.Bulk" Version="1.0.0" />
<PackageVersion Include="Prakrishta.Data.Bulk" Version="1.0.0" />
<PackageReference Include="Prakrishta.Data.Bulk" />
paket add Prakrishta.Data.Bulk --version 1.0.0
#r "nuget: Prakrishta.Data.Bulk, 1.0.0"
#:package Prakrishta.Data.Bulk@1.0.0
#addin nuget:?package=Prakrishta.Data.Bulk&version=1.0.0
#tool nuget:?package=Prakrishta.Data.Bulk&version=1.0.0
Prakrishta.Data.Bulk
High performance, extensible bulk operations for .NET. Prakrishta.Data.Bulk is a provider agnostic, pipeline based bulk engine designed for speed, flexibility, and testability. It complements Prakrishta.Data by enabling large scale insert, update, and delete operations with minimal overhead.
Features
- Fastest‑in‑class bulk insert performance
- TVP‑based stored procedure strategy (fastest for pure inserts)
- Staging table strategy with MERGE (best for upsert/update/delete)
- Zero reflection, zero EF Core overhead
- Linear scaling from 1k → 50k+ rows
- Async/await support
- BenchmarkDotNet‑verified performance
- Works with SQL Server, Azure SQL, LocalDB
- Pure ADO.NET — no EF Core required
- Clean, extensible architecture
Feature Comparison Table
| Feature | Prakrishta (Stored Proc) | Prakrishta (Staging) | EFCore.BulkExtensions | Raw SqlBulkCopy |
|---|---|---|---|---|
| Bulk Insert | ⭐ Fastest | ⭐ Very Fast | Fast | Fast |
| Bulk Update | ❌ | ⭐ Yes (MERGE) | Yes | ❌ |
| Bulk Delete | ❌ | ⭐ Yes (MERGE) | Yes | ❌ |
| Upsert | ❌ | ⭐ Yes (MERGE) | Yes | ❌ |
| TVP Support | ⭐ Yes | Yes | Yes | No |
| Reflection‑Free | ⭐ Yes | ⭐ Yes | ❌ No | Yes |
| EF Core Required | No | No | Yes | No |
Getting Started (Quickstart Guide)
- Install the NuGet package
dotnet add package Prakrishta.Data.Bulk
- Define your entity
public sealed class Customer
{
public int Id { get; set; }
public string Name { get; set; } = default!;
public decimal Balance { get; set; }
public DateTime CreatedOn { get; set; }
}
- Create a bulk engine
Stored Procedure Strategy (Fastest for Inserts)
var engine = BulkEngineFactory.CreateStoredProc(
connectionString: "...",
storedProcName: "dbo.InsertCustomers"
);
The stored procedure should accept a TVP:
CREATE TYPE dbo.CustomerType AS TABLE
(
Id INT,
Name NVARCHAR(200),
Balance DECIMAL(18,2),
CreatedOn DATETIME2
);
CREATE PROCEDURE dbo.InsertCustomers
@Customers dbo.CustomerType READONLY
AS
BEGIN
INSERT INTO dbo.Customers (Id, Name, Balance, CreatedOn)
SELECT Id, Name, Balance, CreatedOn
FROM @Customers;
END
Staging Table Strategy (Best for Upsert/Update/Delete)
var engine = BulkEngineFactory.CreateStaging(
connectionString: "...",
targetTable: "dbo.Customers",
keyColumns: new[] { "Id" }
);
- Execute a bulk insert
await engine.InsertAsync(customers, "dbo.Customers");
- Execute an upsert (staging strategy only)
await engine.UpsertAsync(customers, "dbo.Customers");
Performance Benchmarks
| Rows | Prakrishta (Stored Proc) | Prakrishta (Staging) | Raw Sql | EFCore.BulkExtensions | Result |
|---|---|---|---|---|---|
| 1,000 | 10.0 ms | 12.8 ms | 14.6 ms | 11.4 ms | EFCore slightly faster |
| 10,000 | 37.3 ms | 48.2 ms | 49.26 ms | 87.4 ms | Prakrishta ~2× faster |
| 50,000 | 188.0 ms | 195.0 ms | 203.2 ms | 395.0 ms | Prakrishta ~2× faster |
Key Findings
- EFCore.BulkExtensions performs well for small batches due to low setup overhead.
- Prakrishta’s stored-proc strategy is the fastest overall, especially at large batch sizes.
- Prakrishta’s staging-table strategy is also extremely fast and scales linearly.
- At 10k–50k rows, Prakrishta is 2× faster than EFCore.BulkExtensions.
- Staging-table strategy even outperforms raw SqlBulkCopy at large sizes.
- Performance is linear, predictable, and optimized for high-volume ingestion.
Performance Chart (Markdown)
This chart visualizes the current benchmark results for 50,000 rows, the most meaningful scale for real‑world ETL and ingestion workloads.
Milliseconds (lower is better)
Bulk Insert Performance (50,000 rows)
Prakrishta (Stored Proc) | ████████████████████████████ 188 ms
Prakrishta (Staging) | ██████████████████████████████ 195 ms
Raw SqlBulkCopy | ███████████████████████████████ 203 ms
EFCore.BulkExtensions | █████████████████████████████████████████████ 395 ms
Bulk Insert Performance (10,000 rows)
Prakrishta (Stored Proc) | ████████████████ 37.3 ms
Prakrishta (Staging) | ████████████████████ 48.2 ms
Raw SqlBulkCopy | ████████████████████ 49.2 ms
EFCore.BulkExtensions | █████████████████████████████████ 87.4 ms
Bulk Insert Performance (1,000 rows)
Prakrishta (Stored Proc) | ████████ 10.0 ms
EFCore.BulkExtensions | ████████ 11.4 ms
Prakrishta (Staging) | █████████ 12.8 ms
Raw SqlBulkCopy | ██████████ 14.6 ms
Why Prakrishta Is Faster
Prakrishta.Data.Bulk achieves industry‑grade performance because it:
- Uses pure ADO.NET
- Avoids EF Core overhead
- Eliminates reflection
- Uses optimized TVP ingestion
- Uses linear‑scaling staging tables
- Minimizes SQL Server I/O and logging
- Reduces round trips
- Produces predictable, stable performance curves
This is why Prakrishta Data Bulk engine is:
- Faster than EFCore.BulkExtensions
- Faster than Raw SqlBulkCopy at scale
- The fastest overall at 50K rows (stored‑proc strategy)
Choosing the Right Strategy
Different workloads benefit from different bulk‑loading strategies. Prakrishta.Data.Bulk gives you three optimized paths — each designed for a specific class of problems.
1. Stored Procedure Strategy (TVP‑based) — Best Overall for Inserts
Use when you want:
- Maximum raw insert speed
- Minimal SQL Server overhead
- A single round‑trip to the database
- No MERGE logic
- No staging table
Ideal for:
- High‑volume inserts
- ETL ingestion
- Logging pipelines
- Append‑only tables
- Scenarios where the target table has no complex constraints
Why choose it:
Fastest strategy at 1k, 10k, and 50k rows. Outperforms EFCore.BulkExtensions and even Raw SqlBulkCopy.
2. Staging Table Strategy — Best for Upserts, Updates & Deletes
Use when you need:
- MERGE semantics
- Update‑or‑insert behavior
- Delete‑or‑insert behavior
- Full control over matching keys
- Idempotent ingestion
Ideal for:
- Slowly changing dimensions (SCD)
- Data warehouse loads
- Sync jobs
- Reconciliation pipelines
- Any scenario requiring deterministic upsert logic
Why choose it:
Linear scaling, extremely stable, and 2× faster than EFCore.BulkExtensions at medium and large batch sizes.
3. Raw SqlBulkCopy Strategy — Baseline / Custom Scenarios
Use when you want:
- Absolute minimal overhead
- Full control over the SqlBulkCopy pipeline
- Custom batching or streaming logic
- No MERGE or stored proc logic
Ideal for:
- Internal pipelines
- Custom ETL frameworks
- Scenarios where you want to build your own logic on top of SqlBulkCopy
Why choose it:
Great baseline — and your strategies outperform it at scale.
4. When to Choose Which Strategy
| Scenario | Best Strategy | why |
|---|---|---|
| Pure inserts | Stored Proc | Fastest end‑to‑end path |
| Inserts + updates | Staging | MERGE logic built‑in |
| Inserts + deletes | Staging | MERGE handles delete conditions |
| Large batch ingestion | Stored Proc / Staging | Both scale linearly |
| Small batch inserts | Stored Proc | Lowest overhead |
| EF Core replacement | Stored Proc / Staging | 2× faster at scale |
| Custom pipelines | Raw SqlBulkCopy | Maximum control |
Performance Badges
License
MIT License — free for commercial and open‑source use.
| 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 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. |
-
net8.0
- Microsoft.Data.SqlClient (>= 6.1.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.