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.
| 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.
Install the package of your database provider:
dotnet add package Thinktecture.EntityFrameworkCore.SqlServerEnable 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 builderThen 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.
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.
- Temp-Tables (SQL Server, PostgreSQL, MySQL, SQLite)
- Bulk-Insert (SQL Server, PostgreSQL, MySQL, SQLite)
- Bulk-Update (SQL Server, PostgreSQL, MySQL, SQLite)
- Bulk-Upsert (Insert-or-Update) (SQL Server, PostgreSQL, MySQL, SQLite)
- Entity Inheritance (TPH) in bulk operations and temp tables (SQL Server, PostgreSQL, MySQL, SQLite)
- Truncate Tables (SQL Server, PostgreSQL, MySQL, SQLite)
- Collection Parameters (temp-tables light) (SQL Server, PostgreSQL, MySQL)
- Window Functions Support (RowNumber, Sum, Average, Min, Max) (SQL Server, PostgreSQL, MySQL, SQLite*)
- Bitwise Aggregates (BitOr, BitAnd, BitXor) (PostgreSQL, MySQL)
- Nested (virtual) Transactions
- Table Hints (SQL Server)
- Queries across multiple databases (SQL Server)
- Changing default schema at runtime
- If-Exists / If-Not-Exists checks in migrations (SQL Server, PostgreSQL)
* 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.
- Migrations: include-columns (SQL Server, PostgreSQL)
- Migrations: identity column (SQL Server, PostgreSQL)
- Migrations: (non-)clustered PK (SQL Server)
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-entityframeworkcoreIn 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.