N.EntityFrameworkCore.Extensions.MySql
10.0.5.5
See the version list below for details.
dotnet add package N.EntityFrameworkCore.Extensions.MySql --version 10.0.5.5
NuGet\Install-Package N.EntityFrameworkCore.Extensions.MySql -Version 10.0.5.5
<PackageReference Include="N.EntityFrameworkCore.Extensions.MySql" Version="10.0.5.5" />
<PackageVersion Include="N.EntityFrameworkCore.Extensions.MySql" Version="10.0.5.5" />
<PackageReference Include="N.EntityFrameworkCore.Extensions.MySql" />
paket add N.EntityFrameworkCore.Extensions.MySql --version 10.0.5.5
#r "nuget: N.EntityFrameworkCore.Extensions.MySql, 10.0.5.5"
#:package N.EntityFrameworkCore.Extensions.MySql@10.0.5.5
#addin nuget:?package=N.EntityFrameworkCore.Extensions.MySql&version=10.0.5.5
#tool nuget:?package=N.EntityFrameworkCore.Extensions.MySql&version=10.0.5.5
N.EntityFrameworkCore.Extensions.MySql
High-performance bulk data extensions for Entity Framework Core — MySQL provider. Extends your DbContext with bulk operations, query-based DML, CSV export, and utility helpers — all without loading entities into memory.
Supported operations: BulkDelete · BulkFetch · BulkInsert · BulkMerge · BulkSaveChanges · BulkSync · BulkUpdate · Fetch · DeleteFromQuery · InsertFromQuery · UpdateFromQuery · QueryToCsvFile · SqlQueryToCsvFile
Supports: Multiple Schemas · Complex Properties · Value Converters · Transactions · Synchronous & Asynchronous Execution
Inheritance Models: Table-Per-Concrete · Table-Per-Hierarchy · Table-Per-Type
💬 Feedback & Feature Requests Found a bug or have an idea? Please open an issue on GitHub.
Installation
dotnet add package N.EntityFrameworkCore.Extensions.MySql
Setup
Call SetupEfCoreExtensions() in your DbContext.OnConfiguring override:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseMySql("your-connection-string", ServerVersion.AutoDetect("your-connection-string"))
.SetupEfCoreExtensions();
}
For best bulk-insert performance, enable MySQL local infile support on both the client and server. The provider uses MySqlBulkCopy when possible and falls back to batched inserts when local infile is unavailable.
optionsBuilder
.UseMySql("your-connection-string;AllowLoadLocalInfile=true", ServerVersion.AutoDetect("your-connection-string"))
.SetupEfCoreExtensions();
The MySQL server must also have local_infile=1 enabled.
Usage
BulkInsert
var orders = new List<Order>();
for (int i = 0; i < 10000; i++)
orders.Add(new Order { OrderDate = DateTime.UtcNow, TotalPrice = 2.99 });
dbContext.BulkInsert(orders);
await dbContext.BulkInsertAsync(orders);
BulkUpdate
var products = dbContext.Products.Where(o => o.Price < 5.35M).ToList();
foreach (var product in products) product.Price = 6M;
dbContext.BulkUpdate(products);
await dbContext.BulkUpdateAsync(products);
BulkDelete
var orders = dbContext.Orders.Where(o => o.TotalPrice < 5.35M).ToList();
dbContext.BulkDelete(orders);
await dbContext.BulkDeleteAsync(orders);
BulkMerge (Upsert)
BulkMergeResult<Product> result = dbContext.BulkMerge(products);
Console.WriteLine($"Inserted: {result.RowsInserted}, Updated: {result.RowsUpdated}");
BulkSync
BulkSyncResult<Product> result = dbContext.BulkSync(products);
Console.WriteLine($"Inserted: {result.RowsInserted}, Updated: {result.RowsUpdated}, Deleted: {result.RowsDeleted}");
DeleteFromQuery
dbContext.Products.Where(x => x.Price < 5.35M).DeleteFromQuery();
await dbContext.Products.Where(x => x.Price < 5.35M).DeleteFromQueryAsync();
InsertFromQuery
dbContext.Products
.Where(x => x.Price < 10M)
.InsertFromQuery("ProductsUnderTen", o => new { o.Id, o.Price });
⚠️ MySQL limitation:
InsertFromQuerycannot be used inside a user-managed transaction. MySQL executesCREATE TABLE ... SELECTinternally, which is a DDL statement that causes an implicit commit and will silently commit your active transaction. UseBulkInsertinstead when transactional safety is required.
UpdateFromQuery
dbContext.Products
.Where(x => x.Price == 5.35M)
.UpdateFromQuery(o => new Product { Price = 5.75M });
Transactions
using var transaction = dbContext.Database.BeginTransaction();
try
{
dbContext.BulkInsert(orders);
dbContext.BulkUpdate(products);
transaction.Commit();
}
catch
{
transaction.Rollback();
}
For full documentation including all options, result objects, and the complete API reference, see the main README.
Donations
- 💳 PayPal: Donate via PayPal
- ₿ Bitcoin:
bc1qxqpymnf4gj22nt4wj3wy56ks48fw59v8y9sg9z
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.8)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.8)
- Microting.EntityFrameworkCore.MySql (>= 10.0.8)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on N.EntityFrameworkCore.Extensions.MySql:
| Package | Downloads |
|---|---|
|
N.EntityFrameworkCore.Extensions
Meta-package that references all provider packages: SqlServer, PostgreSql, MySql, Sqlite, and Oracle. Prefer installing the provider-specific package for your database when you only need one provider. |
GitHub repositories
This package is not used by any popular GitHub repositories.