Entity Framework Extensions - Overview

What’s Entity Framework Extensions?

This library allows you to improve your Entity Framework Performance dramatically.

It’s easy to use, and easy to customize.

Example

// Easy to use
ctx.BulkSaveChanges();

// Easy to customize
context.BulkSaveChanges(bulk => bulk.BatchSize = 100);

Is it that simple?

Yes,

That’s why people feel in love so easily with our library.

Who use it?

Already thousands of companies of all sizes and kinds use it:

  • From start-up company with one developer
  • To fortune 100 companies with hundreds of developers

Are you still not using it? Give it one try and you will understand why they choose our library.

Bulk SaveChanges

The BulkSaveChanges methods replace the SaveChanges methods. They work similar, but BulkSaveChanges is way faster!

BulkSaveChanges supports everything:

  • Association (One to One, One to Many, Many to Many, etc.)
  • Complex Type
  • Enum
  • Inheritance (TPC, TPH, TPT)
  • Navigation Property
  • Self-Hierarchy
  • Etc.

Example

Example

var ctx = new EntitiesContext();

ctx.Customers.AddRange(listToAdd); // add
ctx.Customers.RemoveRange(listToRemove); // remove
listToModify.ForEach(x => x.DateModified = DateTime.Now); // modify

// Easy to use
ctx.BulkSaveChanges();

// Easy to customize
context.BulkSaveChanges(bulk => bulk.BatchSize = 100);

Performance Comparisons

Operations 1,000 Entities 2,000 Entities 5,000 Entities
SaveChanges 1,000 ms 2,000 ms 5,000 ms
BulkSaveChanges 90 ms 150 ms 350 ms

Bulk Methods

Bulk methods give you additional flexibility by allowing to customize options such as primary key, columns and more.

All methods your application could require is supported:

  • BulkInsert
  • BulkUpdate
  • BulkDelete
  • BulkMerge (UPSERT operation)
  • BulkSynchronize

Example

Example

var ctx = new EntitiesContext();

// Easy to use
ctx.BulkInsert(list);
ctx.BulkUpdate(list);
ctx.BulkDelete(list);
ctx.BulkMerge(list);

// Easy to customize
context.BulkMerge(customers, 
   bulk => bulk.ColumnPrimaryKeyExpression = customer => customer.Code; });

Performance Comparisons

Operations 1,000 Entities 2,000 Entities 5,000 Entities
SaveChanges 1,000 ms 2,000 ms 5,000 ms
BulkInsert 6 ms 10 ms 15 ms
BulkUpdate 50 ms 55 ms 65 ms
BulkDelete 45 ms 50 ms 60 ms
BulkMerge 65 ms 80 ms 110 ms

FromQuery Operations

FromQuery method allows you to execute UPDATE or DELETE statements without loading entities in the context.

Everything is executed on the database side, so nothing is faster than these methods.

Example

Example

// DELETE all customers that are inactive for more than two years
context.Customers
    .Where(x => x.LastLogin < DateTime.Now.AddYears(-2))
    .DeleteFromQuery();
 
// UPDATE all customers that are inactive for more than two years
context.Customers
    .Where(x => x.Actif && x.LastLogin < DateTime.Now.AddYears(-2))
    .UpdateFromQuery(x => new Customer {Actif = false});

Performance Comparisons

Operations 1,000 Entities 2,000 Entities 5,000 Entities
SaveChanges 1,000 ms 2,000 ms 5,000 ms
DeleteFromQuery 1 ms 1 ms 1 ms
UpdateFromQuery 1 ms 1 ms 1 ms