Registry Mirror
Skip to content

Latest commit

 

History

579 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thinktecture.EntityFrameworkCore

Build NuGet Downloads TestResults

Thinktecture.EntityFrameworkCore.Relational
Thinktecture.EntityFrameworkCore.SqlServer
Thinktecture.EntityFrameworkCore.PostgreSQL
Thinktecture.EntityFrameworkCore.MySql
Thinktecture.EntityFrameworkCore.Sqlite.Core
Thinktecture.EntityFrameworkCore.Sqlite

Thinktecture.EntityFrameworkCore is a set of NuGet packages that extend Entity Framework Core for relational databases. The features are bulk insert, bulk update and bulk upsert of entities, bulk insert and bulk update from a query, temp tables, collection parameters, window functions, bitwise aggregates (PostgreSQL, MySQL), table hints, nested transactions, truncate, queries across databases (tenant databases), the change of the default schema at runtime, and migration helpers. There is no CLI tool and no dotnet tool. The extension methods for application code are in the namespace Thinktecture.

Packages

Package Purpose Depends on Install it directly?
Thinktecture.EntityFrameworkCore.SqlServer Features for SQL Server Thinktecture.EntityFrameworkCore.BulkOperations, Microsoft.EntityFrameworkCore.SqlServer Yes
Thinktecture.EntityFrameworkCore.PostgreSQL Features for PostgreSQL (Npgsql) Thinktecture.EntityFrameworkCore.BulkOperations, Npgsql.EntityFrameworkCore.PostgreSQL Yes
Thinktecture.EntityFrameworkCore.MySql Features for MySQL (MariaDB is not tested) Thinktecture.EntityFrameworkCore.BulkOperations, Microting.EntityFrameworkCore.MySql (MySqlConnector) Yes
Thinktecture.EntityFrameworkCore.Sqlite Features for SQLite, with the native SQLite library Thinktecture.EntityFrameworkCore.Sqlite.Core, Microsoft.EntityFrameworkCore.Sqlite (brings the native SQLite library) Yes
Thinktecture.EntityFrameworkCore.Sqlite.Core The SQLite implementation, without a native SQLite library Thinktecture.EntityFrameworkCore.BulkOperations, Microsoft.EntityFrameworkCore.Sqlite.Core Only for an application that brings its own SQLite build
Thinktecture.EntityFrameworkCore.BulkOperations Provider-independent contracts of the bulk operations, temp tables and collection parameters Thinktecture.EntityFrameworkCore.Relational No, the provider packages reference it
Thinktecture.EntityFrameworkCore.Relational Foundation of all packages Microsoft.EntityFrameworkCore.Relational No, the provider packages reference it

Install one provider package per database provider. The packages SqlServer, PostgreSQL and MySql reference BulkOperations, which references Relational. The package Sqlite references Sqlite.Core, which references BulkOperations.

Getting started

Install the package of your database provider:

dotnet add package Thinktecture.EntityFrameworkCore.SqlServer

Enable the features that you use when you register the DbContext:

using Thinktecture; // required for every extension below

services.AddDbContext<MyDbContext>(builder => builder
   .UseSqlServer(connectionString, sql => sql
      .AddBulkOperationSupport()       // bulk insert/update/upsert, temp tables, truncate
      .AddWindowFunctionsSupport()     // RowNumber, NTile, windowed aggregates
      .AddCollectionParameterSupport() // pass a collection as a query parameter
      .AddTableHintSupport())          // WithTableHints(...), SQL Server only
   .AddNestedTransactionSupport());    // provider-independent, on the outer builder

Then call the feature, for example a bulk insert:

await ctx.BulkInsertAsync(products);

Most features are opt-in and are enabled by a registration method such as AddBulkOperationSupport. The wiki pages of the features name the registration of each feature. PostgreSQL, MySQL and SQLite have the same methods on their options builders where the feature exists, see the feature lists in Performance and Features.

Versions and EF Core compatibility

Since version 7.0, the major version of the packages equals the major version of EF Core. Versions 1.x, 2.x, 3.x and 4.x target EF Core 2.2, 3.1, 5 and 6. The column "Provider packages" names the packages without the prefix Thinktecture.EntityFrameworkCore..

Version EF Core Target framework Provider packages Notes
9.x EF Core 9 net8.0, since 9.1.0 also net9.0 SqlServer, Sqlite
10.x EF Core 10 net10.0 SqlServer, Sqlite, Sqlite.Core since 10.0.1, PostgreSQL since 10.1.0, MySql since 10.6.0 TPH support since 10.6.0
11.x EF Core 11 net11.0 SqlServer, PostgreSQL, MySql, Sqlite, Sqlite.Core AddRowNumberSupport and the *.Testing packages are removed

From version 7.3 to 10.x, AddRowNumberSupport is an obsolete alias of AddWindowFunctionsSupport. The packages Thinktecture.EntityFrameworkCore.Testing, .SqlServer.Testing and .Sqlite.Testing exist up to version 10.x. Version 11.0 removed the alias and these packages. The wiki describes the newest version. A difference of an older version is named where it exists.

The section Choosing the right approach of the wiki explains when to use a bulk operation, a collection parameter or a temp table.

Performance

Features

* SQLite supports RowNumber and NTile; Sum, Average, Min, Max are available on SQL Server, PostgreSQL and MySQL.

MySQL bulk operations insert rows with multi-row INSERT statements by default. The registration AddBulkOperationSupport(useBulkCopy: true) switches every insert of the bulk operations to MySqlBulkCopy (LOAD DATA LOCAL INFILE). Bulk copy needs AllowLoadLocalInfile=true in the connection string and local_infile=ON on the server. A MySQL bulk upsert returns the number of matched rows of its UPDATE plus the number of inserted rows.

Convenience

Best Practices

Extensibility

AI Coding Assistants

An AI agent skill teaches AI coding agents how to consume these packages. The skill lives in the repository PawelGerr/agent-skills under skills/thinktecture-entityframeworkcore. Install it with the skills CLI:

npx skills@latest add PawelGerr/agent-skills --skill thinktecture-entityframeworkcore

In Claude Code, you can install the skill as a plugin instead:

/plugin marketplace add PawelGerr/agent-skills
/plugin install thinktecture-entityframeworkcore@pawelgerr

The library is also indexed by Context7 (MCP) under the id /pawelgerr/thinktecture.entityframeworkcore. See AI Coding Assistants for details.

About

A focused EF Core extension library that adds high‑performance bulk operations, temp‑table support, and other practical SQL enhancements for real‑world applications.

Topics

Resources

Stars

93 stars

Watchers

4 watching

Forks

Releases

Used by

Contributors

Languages