![]() |
VOOZH | about |
dotnet add package PhenX.EntityFrameworkCore.BulkInsert.Sqlite --version 0.5.0
NuGet\Install-Package PhenX.EntityFrameworkCore.BulkInsert.Sqlite -Version 0.5.0
<PackageReference Include="PhenX.EntityFrameworkCore.BulkInsert.Sqlite" Version="0.5.0" />
<PackageVersion Include="PhenX.EntityFrameworkCore.BulkInsert.Sqlite" Version="0.5.0" />Directory.Packages.props
<PackageReference Include="PhenX.EntityFrameworkCore.BulkInsert.Sqlite" />Project file
paket add PhenX.EntityFrameworkCore.BulkInsert.Sqlite --version 0.5.0
#r "nuget: PhenX.EntityFrameworkCore.BulkInsert.Sqlite, 0.5.0"
#:package PhenX.EntityFrameworkCore.BulkInsert.Sqlite@0.5.0
#addin nuget:?package=PhenX.EntityFrameworkCore.BulkInsert.Sqlite&version=0.5.0Install as a Cake Addin
#tool nuget:?package=PhenX.EntityFrameworkCore.BulkInsert.Sqlite&version=0.5.0Install as a Cake Tool
A high-performance, provider-agnostic bulk insert extension for Entity Framework Core 8+. Supports SQL Server, PostgreSQL, SQLite, MySQL and Oracle.
Its main purpose is to provide a fast way to perform simple bulk inserts in Entity Framework Core applications.
For now, it does not support navigation properties, complex types, owned types, shadow properties, or inheritance, but they are in the roadmap.
| Package Name | Description | NuGet Link |
|---|---|---|
PhenX.EntityFrameworkCore.BulkInsert.SqlServer |
For SQL Server | 👁 NuGet |
PhenX.EntityFrameworkCore.BulkInsert.PostgreSql |
For PostgreSQL | 👁 NuGet |
PhenX.EntityFrameworkCore.BulkInsert.Sqlite |
For SQLite | 👁 NuGet |
PhenX.EntityFrameworkCore.BulkInsert.MySql |
For MySql | 👁 NuGet |
PhenX.EntityFrameworkCore.BulkInsert.Oracle |
For Oracle | 👁 NuGet |
PhenX.EntityFrameworkCore.BulkInsert |
Common library | 👁 NuGet |
This library depends on the official Entity Framework Core packages provided by each database vendor.
MySQL is a special case: the Pomelo MySQL package is widely preferred for its superior MySQL feature support. However, the package relies heavily on a single maintainer and does not yet support .NET 10. See the relevant issue.
A community fork is available at https://github.com/microting/Pomelo.EntityFrameworkCore.MySql that addresses this gap. For .NET 10 only, this library takes a dependency on that fork.
Install the NuGet package for your database provider:
# For SQL Server
Install-Package PhenX.EntityFrameworkCore.BulkInsert.SqlServer
# For PostgreSQL
Install-Package PhenX.EntityFrameworkCore.BulkInsert.PostgreSql
# For SQLite
Install-Package PhenX.EntityFrameworkCore.BulkInsert.Sqlite
# For MySql
Install-Package PhenX.EntityFrameworkCore.BulkInsert.MySql
# For Oracle
Install-Package PhenX.EntityFrameworkCore.BulkInsert.Oracle
Register the bulk insert provider in your DbContextOptions:
services.AddDbContext<MyDbContext>(options =>
{
options
// .UseSqlServer(connectionString) // or UseNpgsql or UseSqlite, as appropriate
.UseBulkInsertPostgreSql()
// OR
.UseBulkInsertSqlServer()
// OR
.UseBulkInsertSqlite()
// OR
.UseBulkInsertMySql()
// OR
.UseBulkInsertOracle()
;
});
// Asynchronously
await dbContext.ExecuteBulkInsertAsync(entities);
// Or synchronously
dbContext.ExecuteBulkInsert(entities);
// Common options
await dbContext.ExecuteBulkInsertAsync(entities, options =>
{
options.BatchSize = 1000; // Set the batch size for the insert operation, the default value is different for each provider
});
// Provider specific options, when available, example for SQL Server
await dbContext.ExecuteBulkInsertAsync(entities, (SqlServerBulkInsertOptions o) => // <<< here specify the SQL Server options class
{
options.EnableStreaming = true; // Enable streaming for SQL Server
});
// Provider specific options, supporting multiple providers
await dbContext.ExecuteBulkInsertAsync(entities, o =>
{
o.MoveRows = true;
if (o is SqlServerBulkInsertOptions sqlServerOptions)
{
sqlServerOptions.EnableStreaming = true;
}
else if (o is MySqlBulkInsertOptions mysqlOptions)
{
mysqlOptions.BatchSize = 1000;
}
});
await dbContext.ExecuteBulkInsertReturnEntitiesAsync(entities);
Conflict resolution works by specifying columns that should be used to detect conflicts and the action to take when
a conflict is detected (e.g., update existing rows), using the onConflict parameter.
Match property and must have a unique constraint in the database.Update property. If not specified, the default action is to do nothing (i.e., skip the conflicting rows).Where or the RawWhere property. If not specified, the update action will be applied to all conflicting rows.await dbContext.ExecuteBulkInsertAsync(entities, onConflict: new OnConflictOptions<TestEntity>
{
Match = e => new
{
e.Name,
// ...other columns to match on
},
// Optional: specify the update action, if not specified, the default action is to do nothing
// Excluded is the row being inserted which is in conflict, and Inserted is the row already in the database.
Update = (inserted, excluded) => new TestEntity
{
Price = inserted.Price // Update the Price column with the new value
},
// Optional: specify the condition for the update action
// Excluded is the row being inserted which is in conflict, and Inserted is the row already in the database.
// Using raw SQL condition
RawWhere = (insertedTable, excludedTable) => $"{excludedTable}.some_price > {insertedTable}.some_price",
// OR using a lambda expression
Where = (inserted, excluded) => excluded.Price > inserted.Price,
});
Benchmark projects are available in the directory. Run them to compare performance with raw bulk insert methods and other libraries (https://github.com/borisdj/EFCore.BulkExtensions and https://entityframework-extensions.net/bulk-extensions), using optimized configuration (local Docker is required).
Legend :
PhenX_EntityFrameworkCore_BulkInsert: this libraryRawInsert: naive implementation without any library, using the native provider API (SqlBulkCopy for SQL Server, BeginBinaryImport for PostgreSQL, raw inserts for SQLite)Z_EntityFramework_Extensions_EFCore: https://entityframework-extensions.net/bulk-extensionsEFCore_BulkExtensions: https://github.com/borisdj/EFCore.BulkExtensionsLinq2Db: https://github.com/linq2db/linq2dbPostgreSQL results with 500 000 rows :
SQLite results with 500 000 rows :
MySQL results with 500 000 rows :
Where are the SQL Server and Oracle benchmarks? You can run them yourself.
Contributions are welcome! Please open issues or submit pull requests for bug fixes, features, or documentation improvements.
MIT License. See for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on PhenX.EntityFrameworkCore.BulkInsert.Sqlite:
| Package | Downloads |
|---|---|
|
SU2.Infrastructure
Clean Architecture template — Infrastructure layer (EF Core interceptors for audit/event-dispatch/soft-delete/no-lock, EfRepository, AppDbContext base, Dapper IDbSession, Redis + HybridCache + DistributedLock, Kafka producer/consumer base, MongoDB.EFCore wiring, Hangfire adapters, PhenX bulk-insert for SQL Server/PostgreSQL/MySQL/SQLite/Oracle, Serilog + OpenTelemetry wiring, fake implementations of UseCases interfaces). Numeronym `C15e` = CleanArchitecture. Generation 2026 series. |
|
|
SU2.Web
Clean Architecture template — Web library layer (FastEndpoints BaseEndpoint base classes, InternalAuthorize, middleware: GlobalExceptionHandler/RequestCorrelation/Timeout, JsonErrorMessageResolver, CORS + Compression setup helpers, ForwardCurrentUserHandler, CurrentUser/CurrentUserOptions services, FastEndpointsErrorBuilder, ServiceConfigs + OptionConfigs + MediatorConfig + MiddlewareConfig extension methods). Numeronym `C15e` = CleanArchitecture. Generation 2026 series. |
Showing the top 1 popular GitHub repositories that depend on PhenX.EntityFrameworkCore.BulkInsert.Sqlite:
| Repository | Stars |
|---|---|
|
Spottarr/Spottarr
A modern spotnet client and index for your *arr apps.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.5.0 | 1,293 | 3/21/2026 |
| 0.4.7 | 342 | 1/18/2026 |
| 0.4.6 | 474 | 12/21/2025 |
| 0.4.5 | 505 | 11/16/2025 |
| 0.4.4 | 782 | 10/15/2025 |
| 0.4.3 | 212 | 10/12/2025 |
| 0.4.2 | 617 | 9/14/2025 |
| 0.4.1 | 459 | 7/16/2025 |
| 0.4.0 | 322 | 6/22/2025 |
| 0.3.2 | 346 | 6/8/2025 |
| 0.3.1 | 191 | 6/7/2025 |
| 0.3.0 | 222 | 6/2/2025 |
| 0.2.3 | 226 | 5/26/2025 |
| 0.2.2 | 220 | 5/26/2025 |
| 0.2.1 | 185 | 5/24/2025 |
| 0.2.0 | 152 | 5/24/2025 |
| 0.1.0 | 224 | 5/22/2025 |
| 0.0.3 | 244 | 5/20/2025 |
| 0.0.2 | 237 | 5/20/2025 |
| 0.0.1 | 229 | 5/20/2025 |