Skip to content

Commit a329eb0

Browse files
Update docs
1 parent 241b350 commit a329eb0

File tree

6 files changed

+469
-178
lines changed

6 files changed

+469
-178
lines changed

entityframework-extensions.net/pages/documentations/bulk-delete.md

+90-42
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
Title: EF Core Bulk Delete | Optimize Data Deletion for EF6 and EF Core
2+
Title: Bulk Delete in EF Core | Delete entities without tracking them
33
MetaDescription: Efficiently delete Entity Framework data with EF Core Bulk Delete Extensions. Customize options to quickly delete large numbers of entities with ease, compatible with all EF versions including EF Core 7, 6, 5, 3, and EF6. Optimize your database operations - try it now.
4-
LastMod: 2025-03-18
4+
LastMod: 2025-05-11
55
---
66

77
# Bulk Delete /n Swiftly perform delete operations on thousands of entities in EF Core
@@ -23,7 +23,30 @@ Our library also offers several other ways to delete your entities even more eas
2323
- [Delete by Key](/delete-by-key)
2424
- [Delete Range by Key](/delete-range-by-key)
2525

26-
### Performance Comparison
26+
## 🔑 Key Benefits
27+
28+
One of the main reasons people use our Bulk Delete is to **delete entities exactly the way they want** — without having to load them into memory or deal with tracking issues. You stay in control while getting top performance.
29+
30+
-**Delete the way you want:** Use custom keys, delete related entities (graph), or target specific conditions.
31+
-**Extremely fast:** Delete thousands or millions of rows in seconds.
32+
-**No need to load entities:** Avoid change tracking — delete directly from your data.
33+
-**Flexible with hundreds of options:** Choose how relationships are handled, how keys are matched, and more.
34+
35+
## 🔍 What is supported?
36+
37+
Our library supports all the common scenarios — and almost everything you can do with EF Core and EF6!
38+
39+
- ✅ The latest Entity Framework Core version: EF Core 9
40+
- ✅ All previous EF Core versions: EF Core 2 to 8
41+
- ✅ All Entity Framework versions: EF6, EF5, EF4, and EF Classic
42+
- ✅ All major database providers: SQL Server, SQL Azure, PostgreSQL, MySQL, MariaDB, SQLite, and Oracle
43+
- ✅ All inheritance mapping strategies: TPC, TPH, and TPT
44+
- ✅ Complex types / owned entity types
45+
- ✅ Enums
46+
- ✅ Value converters (EF Core)
47+
- ✅ And much more — even shadow properties!
48+
49+
### 🚀 Performance Comparison
2750

2851
| Operations | 1,000 Entities | 2,000 Entities | 5,000 Entities |
2952
| :-------------- | -------------: | -------------: | -------------: |
@@ -41,15 +64,6 @@ The `BulkDelete` method is **fast** but also **flexible** to let you handle vari
4164
- [Delete with future action](#delete-with-future-action)
4265
- [More scenarios](#more-scenarios)
4366

44-
### What is supported?
45-
- All Entity Framework Core Version: EF Core 9, EF Core 8, EF Core 7, EF Core 6, EF Core 5, EF Core 3
46-
- All Entity Framework Version: EF6, EF5, EF4
47-
- All Inheritances (TPC, TPH, TPT)
48-
- Complex Type/Owned Entity Type
49-
- Enum
50-
- Value Converter (EF Core)
51-
- And more!
52-
5367
### Advantages
5468
- Easy to use
5569
- Flexible
@@ -137,33 +151,67 @@ Hundreds of scenarios have been solved and are now supported.
137151
The best way to ask for a special request or to find out if a solution for your scenario already exists is by contacting us:
138152
139153

140-
## Documentation
141-
142-
### BulkDelete
143-
144-
###### Methods
145-
146-
| Name | Description | Example |
147-
| :--- | :---------- | :------ |
148-
| `BulkDelete<T>(items)` | Bulk delete entities in your database. | [EFCore](https://dotnetfiddle.net/gwc9hl) / [EF6](https://dotnetfiddle.net/4Jv1H6)|
149-
| `BulkDelete<T>(items, options)` | Bulk delete entities in your database. | [EFCore](https://dotnetfiddle.net/Qek2MJ) / [EF6](https://dotnetfiddle.net/IedG1h) |
150-
| `BulkDeleteAsync<T>(items)` | Bulk delete entities asynchronously in your database. | [EFCore](https://dotnetfiddle.net/MJLo2d) / [EF6](https://dotnetfiddle.net/n5OhXL) |
151-
| `BulkDeleteAsync<T>(items, cancellationToken)` | Bulk delete entities asynchronously in your database. | [EFCore](https://dotnetfiddle.net/rRL627) / [EF6](https://dotnetfiddle.net/RfSB6I) |
152-
| `BulkDeleteAsync<T>(items, options, cancellationToken)` | Bulk delete entities asynchronously in your database. | [EFCore](https://dotnetfiddle.net/SZ54Px) / [EF6](https://dotnetfiddle.net/r1Hkw7) |
153-
154-
###### Options
155-
More options can be found here:
156-
157-
- [Audit](https://entityframework-extensions.net/audit)
158-
- [Batch](https://entityframework-extensions.net/batch)
159-
- [Column](https://entityframework-extensions.net/column)
160-
- [Context Factory](https://entityframework-extensions.net/context-factory)
161-
- [Execute Event](https://entityframework-extensions.net/execute-event)
162-
- [Identity](https://entityframework-extensions.net/identity)
163-
- [Include Graph](https://entityframework-extensions.net/include-graph)
164-
- [Key](https://entityframework-extensions.net/key)
165-
- [Logging](https://entityframework-extensions.net/logging)
166-
- [Temporary Table](https://entityframework-extensions.net/temporary-table)
167-
- [Transaction](https://entityframework-extensions.net/transaction)
168-
- [Transient Error](https://entityframework-extensions.net/transient-error)
169-
- [SQL Server](https://entityframework-extensions.net/sql-server)
154+
## Bulk Delete Options
155+
156+
### Configuring Options
157+
158+
We already saw in previous articles how to pass options to the `BulkDelete` method — but here’s a quick recap:
159+
160+
```csharp
161+
// Using a lambda expression (only works with one option)
162+
context.BulkDelete(list, options => options.IncludeGraph = true);
163+
164+
// Using a lambda expression with a body (works with one or multiple options)
165+
context.BulkDelete(list, options =>
166+
{
167+
options.IncludeGraph = true;
168+
options.ColumnPrimaryKeyExpression = x => new { x.ID };
169+
});
170+
171+
// Using a `BulkOperationOption` instance
172+
var options = context.CreateBulkOptions<EntitySimple>();
173+
options.IncludeGraph = true;
174+
options.ColumnPrimaryKeyExpression = x => new { x.ID };
175+
176+
context.BulkDelete(list, options);
177+
```
178+
179+
> 💡 Tip: Using a `BulkOperationOption` instance is useful when you want to reuse the same configuration across multiple operations or keep your setup code more organized.
180+
181+
### Common Options
182+
183+
- Bulk Delete Behavior
184+
- **DeletePrimaryKeyAndFormula:** Specify a hardcoded SQL to include additional logic—along with the primary key—to check if the entity matches an existing row in the database. Only rows that also match the formula will be deleted.
185+
- **DeleteStagingTableFilterFormula:** Specify a hardcoded SQL if you want to filter which rows should be deleted using a staging table.
186+
- Matched Behavior
187+
- **DeleteMatchedAndFormula:** After matching rows by primary key, you can specify an additional SQL condition to delete only the rows that also satisfy this formula.
188+
- **DeleteMatchedAndConditionExpression:** After matching rows by primary key, you can specify additional properties using a lambda expression. All specified property values must match between the entity and the database for the row to be deleted.
189+
- **DeleteMatchedAndConditionNames:** After matching rows by primary key, you can specify additional properties using a list of strings. All specified property values must match between the entity and the database for the row to be deleted.
190+
- **DeleteMatchedAndOneNotConditionExpression:** After matching rows by primary key, you can specify additional properties using a lambda expression. At least one of the specified property values must differ between the entity and the database for the row to be deleted.
191+
- **DeleteMatchedAndOneNotConditionNames:** After matching rows by primary key, you can specify additional properties using a list of strings. At least one of the specified property values must differ between the entity and the database for the row to be deleted.
192+
- **IgnoreOnDeleteMatchedAndConditionExpression:** Use a lambda expression to select the properties you want to ignore. These properties will be excluded from the comparison performed by `DeleteMatchedAndConditionExpression`, and all other properties will be used for the match.
193+
- **IgnoreOnDeleteMatchedAndConditionNames:** Use a list of strings to select the properties you want to ignore. These properties will be excluded from the comparison performed by `DeleteMatchedAndConditionNames`, and all other properties will be used for the match.
194+
- **IgnoreOnDeleteMatchedAndOneNotConditionExpression:** Use a lambda expression to select the properties you want to ignore. These properties will be excluded from the comparison performed by `DeleteMatchedAndOneNotConditionExpression`, and all other properties will be used for the match.
195+
- **IgnoreOnDeleteMatchedAndOneNotConditionNames:** Use a list of strings to select the properties you want to ignore. These properties will be excluded from the comparison performed by `DeleteMatchedAndOneNotConditionNames`, and all other properties will be used for the match.
196+
- Behavior
197+
- **IncludeGraph:** Set to `true` if you want to delete both the main entities and their related entities. For example, if you pass a list of `Order` that includes `OrderItem`, both will be deleted. Be careful: if you want to apply specific options to a related entity type, you’ll need to configure them using `IncludeGraphBuilder`. Only compatible with EF Core
198+
- **IncludeGraphBuilder:** Required only if `IncludeGraph = true` **and** you need to customize how a related entity type is deleted. Use a lambda expression to control how each entity in the graph should be deleted.
199+
- Properties & Columns
200+
- **ColumnPrimaryKeyExpression:** Choose which properties should be part of the key by using a lambda expression. Only rows that match the key will be deleted.
201+
- **ColumnPrimaryKeyNames:** Choose which properties should be part of the key by using a list of strings. Only rows that match the key will be deleted.
202+
- Optimization
203+
- **Batch:** Customize the `BatchSize`, `BatchTimeout`, and `BatchDelayInterval` to improve performance and control how deleted entities are grouped and executed.
204+
- **Hint:** Use `QueryHint` or `TableHintSql` to apply SQL hints for additional performance tuning.
205+
- **UseTableLock:** Set to `true` to lock the destination table during the delete operation, which can improve performance by reducing row-level locks and avoiding lock escalation. This is especially useful when inserting a large number of rows.
206+
- General
207+
- **Audit:** Track deleted entities by using the `UseAudit` and `AuditEntries` options. [Learn more here](/audit)
208+
- **FutureAction:** Batch multiple delete operations and execute them later using the `ExecuteFuture` or `ExecuteFutureAsync` methods.
209+
- **Log:** Log all executed SQL statements using the `Log`, `UseLogDump`, and `LogDump` options. [Learn more here](/logging)
210+
- **RowsAffected:** Use `UseRowsAffected = true`, then access `ResultInfo.RowsAffected` or `ResultInfo.RowsAffectedDeleted` to get the number of entities deleted. [Learn more here](/rows-affected)
211+
212+
213+
## Conclusion
214+
215+
The `BulkDelete` method is very powerful. One of its biggest benefits is that you don’t need to use the change tracker or retrieve your entities before deleting them (which often doesn’t make much sense anyway). The major benefit is the performance gain—but you can also delete using a custom key or even delete an entire entity graph.
216+
217+
Perfect when you want to delete thousands of rows fast—without slowing down your app.

entityframework-extensions.net/pages/documentations/bulk-insert-optimized.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Title: EF Core 8 Bulk Insert Optimized | Improve your Insert Performance
33
MetaDescription: Boost EF Core insert performance with BulkInsertOptimized. Easily insert large numbers of entities without outputting values for the best performance. Get hints and recommendations about what could be improved to improve insert performance - try it now.
4-
LastMod: 2025-03-21
4+
LastMod: 2025-05-11
55
---
66

77
# Bulk Insert Optimized /n Instantly maximize your insert performance in EF Core 9
@@ -87,6 +87,18 @@ The "example 2" is not considered as optimized. For SQL Server, we cannot direct
8787
- Value Converter (EF Core)
8888
- And more!
8989

90+
## Bulk Insert Optimized Options
91+
92+
Please refer to the [Bulk Insert Options](/bulk-insert#bulk-insert-options) documentation
93+
94+
## Troubleshooting
95+
96+
Please refer to the [Bulk Insert - Troubleshooting](/bulk-insert#troubleshooting) documentation
97+
98+
## Limitations
99+
100+
Please refer to the [Bulk Insert - Limitations](/bulk-insert#limitations) documentation
101+
90102
## Conclusion
91103

92104
The `BulkInsertOptimized` method is a powerful tool, yet it is very similar to [`BulkInsert`](/bulk-insert). As specified, the major difference lies in the fact that `BulkInsertOptimized` does not automatically output values. Instead, it returns a `BulkOptimizedAnalysis`, which informs you whether the strategy employed for insertion is the most efficient, and explains the reasons when it is not.

entityframework-extensions.net/pages/documentations/bulk-insert.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Title: Bulk Insert in EF Core / EF6 | The Fastest Way to Insert Entities
33
MetaDescription: Boost your EF Core inserts performance by up to 15x, reducing insert time by 94% with EF Extensions. Use BulkInsert to handle thousands of entities with less memory and more control. Fully supports EF Core 9 to 2 and EF6. Try the live benchmark now!
4-
LastMod: 2025-05-07
4+
LastMod: 2025-05-11
55
---
66

77
# Bulk Insert /n Boost your EF Core insert performance now
@@ -34,7 +34,7 @@ One of the main reasons people use our Bulk Insert with Entity Framework is for
3434

3535
## 🔍 What is supported?
3636

37-
Our library supports all the common scenarios — and almost everything you can do with Entity Framework!
37+
Our library supports all the common scenarios — and almost everything you can do with EF Core and EF6!
3838

3939
- ✅ The latest Entity Framework Core version: EF Core 9
4040
- ✅ All previous EF Core versions: EF Core 2 to 8
@@ -141,7 +141,7 @@ context.BulkInsert(list, options);
141141
- **InsertIfNotExists:** Set to `true` if you only want to insert entities that don’t already exist in your database.
142142
- **InsertKeepIdentity:** Set to `true` if you want to insert entities with their identity value. For SQL Server, the library will automatically handle the `SET IDENTITY_INSERT [tableName] ON` and `SET IDENTITY_INSERT [tableName] OFF` commands.
143143
- **InsertNotMatchedAndFormula:** Specify a hardcoded SQL if you want to add custom logic to filter which rows should be inserted.
144-
- **InsertPrimaryKeyAndFormula:** Specify a hardcoded SQL if you want to add custom logic to define the primary key. This option usually only makes sense when `InsertIfNotExists = true`.
144+
- **InsertPrimaryKeyAndFormula:** Specify a hardcoded SQL to include additional logic—along with the primary key—to check if the entity matches an existing row in the database. Only rows that also match the formula will be inserted. This option usually only makes sense when `InsertIfNotExists = true`.
145145
- **InsertStagingTableFilterFormula:** Specify a hardcoded SQL if you want to filter which rows should be inserted using a staging table.
146146
- Behavior
147147
- **AutoTruncate:** Set to `true` if you want string values to be automatically truncated to match the maximum database length before being inserted. This option is especially useful because `SqlCommand` and `SqlBulkCopy` can behave differently when a string is too long. (See [Issue #333](https://github.com/zzzprojects/EntityFramework-Extensions/issues/333#issuecomment-1041494634))
@@ -151,13 +151,13 @@ context.BulkInsert(list, options);
151151
- Properties & Columns
152152
- **ColumnInputExpression:** Choose which properties should be inserted by using a lambda expression to select them. All other properties will be ignored.
153153
- **ColumnInputNames:** Choose which properties should be inserted by using a list of strings to select them. All other properties will be ignored.
154+
- **ColumnPrimaryKeyExpression:** Choose which properties should be part of the key by using a lambda expression. Only rows that match the key will be inserted. This option only works when `InsertIfNotExists = true`.
155+
- **ColumnPrimaryKeyNames:** Choose which properties should be part of the key by using a list of strings. Only rows that match the key will be inserted. This option only works when `InsertIfNotExists = true`.
154156
- **IgnoreOnInsertExpression:** Choose which properties should be ignored by using a lambda expression to select them. All other properties will be inserted.
155157
- **IgnoreOnInsertNames:** Choose which properties should be ignored by using a list of strings to select them. All other properties will be inserted.
156-
- **PrimaryKeyExpression:** Choose which properties should be part of the key by using a lambda expression. This option only works when `InsertIfNotExists = true`.
157-
- **PrimaryKeyNames:** Choose which properties should be part of the key by using a list of strings. This option only works when `InsertIfNotExists = true`.
158158
- Optimization
159159
- **AutoMapOutputDirection:** Set to `false` to disable the default output mapping. This can dramatically improve performance when you don’t need to retrieve values normally returned by the database (like identity, computed, or default values). Alternatively, you can use the [BulkInsertOptimized](/bulk-insert-optimized) method for even faster inserts.
160-
- **Batch:** Customize the `BatchSize`, `BatchTimeout`, and `BatchDelayInterval` to improve performance and control how inserted entities are grouped and executed.
160+
- **Batch:** Customize the `BatchSize`, `BatchTimeout`, and `BatchDelayInterval` to improve performance and control how inserts are grouped and executed.
161161
- **Hint:** Use `QueryHint` or `TableHintSql` to apply SQL hints for additional performance tuning.
162162
- **UseTableLock:** Set to `true` to lock the destination table during the insert operation, which can improve performance by reducing row-level locks and avoiding lock escalation. This is especially useful when inserting a large number of rows.
163163
- Providers Specific

0 commit comments

Comments
 (0)