Batch Update

Introduction

Batch Update allows you to improve EF performance by updating multiple records in a database from a LINQ Query without loading entities.

Why Batch Delete?

For HUGE performance gains, everything is executed on the database side. To use batch update, you will need to use a third-party library.

Example

// using Z.EntityFramework.Plus; // Don't forget to include this.

// UPDATE all users inactive for 2 years
ctx.Users.Where(x => x.LastLoginDate < DateTime.Now.AddYears(-2))
.Update(x => new User() { IsSoftDeleted = 1 });

Supported Libraries

Library Type EF Version Support Doc Features
Z.EntityFramework.Plus FREE EF5
EF6
EF Core
< 1 Day Yes Audit
Batch Delete
Batch Update
Cache
Deferred Query
Filter
Future
Include Filter
Include Optimized

Unsuported Libraries

Use these libraries at your risk!

Library Type EF Version Support Doc Features
EFUtilities FREE EF5
EF6
No No Bulk Insert
Batch Delete
Batch Update
Include Optimized
EntityFramework.Extended FREE EF5
EF6
No Yes Audit
Batch Delete
Batch Update
Cache
Future