Bulk insert extension for EntityFramework 4.1.10311+.
Insert large amount of data over 20 times faster than regular insert.
Supports DB first and code first.

untitled-1.png

Nuget

EF4

PM> Install-Package EntityFramework.BulkInsert-ef4
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef4

EF5

PM> Install-Package EntityFramework.BulkInsert-ef5
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef5

EF6

PM> Install-Package EntityFramework.BulkInsert-ef6
https://www.nuget.org/packages/EntityFramework.BulkInsert-ef6

Supports

  • All EntityFramework releases available in nuget
  • Code-First
  • Database-First (from ef 6.0.0)
  • Inserting Table-Per-Hirerachy entities
  • Inserting Table-Per-Type entities

Usage

Extension itself is in namespace EntityFramework.BulkInsert.Extensions. So to reveal the extension method add using
using EntityFramework.BulkInsert.Extensions;

And then you can do this
context.BulkInsert(entities);


NB! This action is executed immediately in its own transaction. To combine bulk insert with DbContext, TransactionScope must be used.
using (var ctx = GetContext())
{
  using (var transactionScope = new TransactionScope())
  {
    // some stuff in dbcontext

    ctx.BulkInsert(entities);

    ctx.SaveChanges();
    transactionScope.Complete();
  }
}

Read more from documentation

Donate

Donating to EntityFramework.BulkInsert will help:
  • Support speedy bug fixes
  • Porting to other versions of EntityFramework
  • Implement new features

donate

Last edited Apr 29 at 11:58 PM by maxlego, version 16