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.
https://efbulkinsert.codeplex.com/
Nuget
EF4
PM> Install-Package EntityFramework.BulkInsert-ef4https://www.nuget.org/packages/EntityFramework.BulkInsert-ef4
EF5
PM> Install-Package EntityFramework.BulkInsert-ef5https://www.nuget.org/packages/EntityFramework.BulkInsert-ef5
EF6
PM> Install-Package EntityFramework.BulkInsert-ef6https://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
0 Response to "EntityFramework.BulkInsert..."
Post a Comment