Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zzzprojects/EntityFramework-Extensions?tab=readme-ov-file

Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.
https://github.com/zzzprojects/EntityFramework-Extensions?tab=readme-ov-file

batch bulk-inserts bulk-operation bulk-savechanges c-sharp csharp dotnet dotnet-core dotnet-standard ef6 efcore entity-framework entity-framework-core entityframework sqlbulkcopy

Last synced: 3 months ago
JSON representation

Entity Framework Bulk Operations | Improve Entity Framework performance with Bulk SaveChanges, Insert, update, delete and merge for SQL Server, SQL Azure, SQL Compact, MySQL and SQLite.

Awesome Lists containing this project

README

        

# What's Entity Framework Extensions?

Entity Framework Extensions is a library that dramatically improves EF performances by using bulk and batch operations.

People using this library often report performance enhancement by 50x times and more!

## Improve Entity Framework performance with Bulk SaveChanges and Bulk Operations

Solve Entity Framework performance issue when saving with high performance bulk operations and hundreds of flexibles feature.
- BulkSaveChanges
- BulkInsert
- BulkUpdate
- BulkDelete
- BulkMerge
- DeleteFromQuery
- UpdateFromQuery

```csharp
var context = new CustomerContext();
// ... context code ...

// Easy to use
context.BulkSaveChanges();

// Easy to customize
context.BulkSaveChanges(operation => operation.BatchSize = 1000);
```

```csharp
// Perform specific bulk operations
context.BulkDelete(customers);
context.BulkInsert(customers);
context.BulkUpdate(customers);

// Customize Primary Key
context.BulkMerge(customers, operation => {
operation.ColumnPrimaryKeyExpression = customer => customer.Code;
});
```

##### Scalable
SQL Server - Benchmarks

| Operations | 100 Rows | 1,000 Rows | 10,000 Rows |
| ------------------ | -------: | ---------: | ----------: |
|**BulkSaveChanges** | 20 ms | 200 ms | 2,000 ms |
|**BulkInsert** | 2 ms | 6 ms | 25 ms |
|**BulkUpdate** | 27 ms | 50 ms | 80 ms |
|**BulkDelete** | 25 ms | 45 ms | 70 ms |
|**BulkMerge** | 30 ms | 65 ms | 160 ms |

##### Extensible
Support Multiple SQL Providers:
- SQL Server 2008+
- SQL Azure
- SQL Compact
- MySQL
- SQLite
- PostgreSQL
- Oracle

## Download

### Entity Framework Core (EF Core)
download

```
PM> Install-Package Z.EntityFramework.Extensions.EFCore
```

### Entity Framework 6 (EF6)
download

```
PM> Install-Package Z.EntityFramework.Extensions
```

### Entity Framework 5 (EF5)
download

```
PM> Install-Package Z.EntityFramework.Extensions.EF5
```

_* PRO Version unlocked for the current month_

## BulkSaveChanges

##### Problem
You need to save hundreds or thousands of entities, but you are not satisfied with Entity Framework performance.

##### Solution
BulkSaveChanges is exactly like SaveChanges but performs way faster. It’s easy to use, you only need to replace “SaveChanges” by “BulkSaveChanges”, and you are done!

```
// Upgrade SaveChanges performance with BulkSaveChanges
var context = new CustomerContext();
// ... context code ...

// Easy to use
context.BulkSaveChanges();

// Easy to customize
context.BulkSaveChanges(operation => operation.BatchSize = 1000);
```

##### Scalability
BulkSaveChanges is as fast as SaveChanges with one entity and quickly become **10-50x faster** with hundreds and thousands of entities.

## Bulk Operations
##### Problem
You need even more performance than BulkSaveChanges, save detached entities or save entities in a specific order.

##### Solution
Use bulk operations such as bulk insert, update, delete and merge which perform operations on specified entities and bypass the change tracker to increase performance.

```csharp
// Perform specific bulk operations on entities
context.BulkDelete(customers);
context.BulkInsert(customers);
context.BulkUpdate(customers);
context.BulkMerge(customers);
```

##### Maintainability
Bulk Operation directly uses the Entity Framework Model. Even if you change column name or change inheritance (TPC, TPH, TPT), Bulk Operation will continue to work as expected.

## Custom Key
##### Problem
You need to perform an update, delete, or merge using a specific custom key like the custom code.

##### Solution
Specify your own key by customizing the operation.

```csharp
// Use flexible features such as specifying the primary key
context.BulkMerge(customers, operation => {
operation.ColumnPrimaryKeyExpression = customer => customer.Code;
});
```

##### Flexibility
Bulk operations offer hundreds of customization such as BatchSize, Custom Key, Custom Mapping, etc.

## PRO Version
_PRO Version unlocked for the current month_

Features | [PRO Version](https://entityframework-extensions.net/#pro)
-------- | :-------------:
Bulk SaveChanges | Yes
Bulk Insert | Yes
Bulk Update | Yes
Bulk Delete | Yes
Bulk Merge | Yes
DeleteFromQuery | Yes
UpdateFromQuery | Yes
Commercial License | Yes
Royalty-Free | Yes
Support & Upgrades (1 year) | Yes
Learn more about the **[PRO Version](https://entityframework-extensions.net/#pro)**

## Contribute

The best way to contribute is by **spreading the word** about the library:

- Blog it
- Comment it
- Star it
- Share it

A **HUGE THANKS** for your help.

## More Projects

- Projects:
- [EntityFramework Extensions](https://entityframework-extensions.net/)
- [Dapper Plus](https://dapper-plus.net/)
- [C# Eval Expression](https://eval-expression.net/)
- Learn Websites
- [Learn EF Core](https://www.learnentityframeworkcore.com/)
- [Learn Dapper](https://www.learndapper.com/)
- Online Tools:
- [.NET Fiddle](https://dotnetfiddle.net/)
- [SQL Fiddle](https://sqlfiddle.com/)
- [ZZZ Code AI](https://zzzcode.ai/)
- and much more!

To view all our free and paid projects, visit our website [ZZZ Projects](https://zzzprojects.com/).