N.EntityFrameworkCore.Extensions.MySql 10.0.5.5

There is a newer version of this package available.
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
                    
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="N.EntityFrameworkCore.Extensions.MySql" Version="10.0.5.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="N.EntityFrameworkCore.Extensions.MySql" Version="10.0.5.5" />
                    
Directory.Packages.props
<PackageReference Include="N.EntityFrameworkCore.Extensions.MySql" />
                    
Project file
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 N.EntityFrameworkCore.Extensions.MySql --version 10.0.5.5
                    
#r "nuget: N.EntityFrameworkCore.Extensions.MySql, 10.0.5.5"
                    
#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 N.EntityFrameworkCore.Extensions.MySql@10.0.5.5
                    
#: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=N.EntityFrameworkCore.Extensions.MySql&version=10.0.5.5
                    
Install as a Cake Addin
#tool nuget:?package=N.EntityFrameworkCore.Extensions.MySql&version=10.0.5.5
                    
Install as a Cake Tool

N.EntityFrameworkCore.Extensions.MySql

latest version downloads

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: InsertFromQuery cannot be used inside a user-managed transaction. MySQL executes CREATE TABLE ... SELECT internally, which is a DDL statement that causes an implicit commit and will silently commit your active transaction. Use BulkInsert instead 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
10.0.5.6 589 8/31/2026
10.0.5.5 155 6/16/2026
10.0.5.4 152 5/31/2026
10.0.5.3 125 5/27/2026
10.0.5.2 133 4/29/2026