I'm looking for the fastest way of inserting into Entity Framework
There isare some third party library-party libraries supporting Bulk Insert available:
- Z.EntityFramework.Extensions (Recommended)
- EFUtilities
- EntityFramework.BulkInsert
See: Entity Framework Bulk Insert library
Be careful, when choosing a bulk insert library. Only Entity Framework Extensions supportsupports all kind of associations and inheritanceinheritances and it's the only one still supported.
Disclaimer: I'm the owner of Entity Framework Extensions
This library allows you to perform all bulk operations you need for your scenarios:
- Bulk SaveChanges
- Bulk Insert
- Bulk Delete
- Bulk Update
- Bulk Merge
Example
// Easy to use context.BulkSaveChanges(); // Easy to customize context.BulkSaveChanges(bulk => bulk.BatchSize = 100); // Perform Bulk Operations context.BulkDelete(customers); context.BulkInsert(customers); context.BulkUpdate(customers); // Customize Primary Key context.BulkMerge(customers, operation => { operation.ColumnPrimaryKeyExpression = customer => customer.Code; });