You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entityframework-extensions.net/pages/documentations/bulk-delete.md
+90-42
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
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
3
3
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
5
5
---
6
6
7
7
# 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
23
23
-[Delete by Key](/delete-by-key)
24
24
-[Delete Range by Key](/delete-range-by-key)
25
25
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
> 💡 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.
Copy file name to clipboardExpand all lines: entityframework-extensions.net/pages/documentations/bulk-insert-optimized.md
+13-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
Title: EF Core 8 Bulk Insert Optimized | Improve your Insert Performance
3
3
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
5
5
---
6
6
7
7
# 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
87
87
- Value Converter (EF Core)
88
88
- And more!
89
89
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
+
90
102
## Conclusion
91
103
92
104
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.
Copy file name to clipboardExpand all lines: entityframework-extensions.net/pages/documentations/bulk-insert.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
Title: Bulk Insert in EF Core / EF6 | The Fastest Way to Insert Entities
3
3
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
5
5
---
6
6
7
7
# 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
34
34
35
35
## 🔍 What is supported?
36
36
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!
38
38
39
39
- ✅ The latest Entity Framework Core version: EF Core 9
-**InsertIfNotExists:** Set to `true` if you only want to insert entities that don’t already exist in your database.
142
142
-**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.
143
143
-**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`.
145
145
-**InsertStagingTableFilterFormula:** Specify a hardcoded SQL if you want to filter which rows should be inserted using a staging table.
146
146
- Behavior
147
147
-**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))
-**ColumnInputExpression:** Choose which properties should be inserted by using a lambda expression to select them. All other properties will be ignored.
153
153
-**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`.
154
156
-**IgnoreOnInsertExpression:** Choose which properties should be ignored by using a lambda expression to select them. All other properties will be inserted.
155
157
-**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`.
158
158
- Optimization
159
159
-**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.
161
161
-**Hint:** Use `QueryHint` or `TableHintSql` to apply SQL hints for additional performance tuning.
162
162
-**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.
0 commit comments