BulkInsert allows you to improve EF performance by inserting multiple entities with bulk operations.
For HUGE performance gains, Entity Framework makes one database round-trip for each entity to insert.
So if you want to add 10,000 entities, 10,000 database round trip will be required which is INSANELY slow. To use BulkInsert, you will need to use a third-party library.
|Operations||1,000 Entities||2,000 Entities||5,000 Entities|
|BulkInsert||6 ms||10 ms||15 ms|
|SaveChanges||1,000 ms||2,000 ms||5,000 ms|
Google Related Searches
- Entity Framework Insert Multiple Records
- Entity Framework Insert Multiple Rows
- Entity Framework Add Range
StackOverflow Related Questions
- Fastest way of inserting many parent and child records
- Bulk Insert in Entity Framework v6.1
- C# & EF: bulkinsert related objects
- Entity framework 6 code first Many to many insert slow
- Insert thousands of many to many links to the DB quickly
- Entity Framework Bulk Insert Throws KeyNotFoundException error
- Bulk insert from a csv file using Entity Framework
// using Z.EntityFramework.Extensions; // Don't forget to include this. // Easy to use context.BulkInsert(list); // Easy to customize context.BulkInsert(list, bulk => bulk.BatchSize = 100);
|Z.EntityFramework.Extensions||PRO||EF6||< 1 Day||Yes||Bulk SaveChanges
Use these libraries at your risk!