<t>To your remark in the comments to your question:<br/>
<br/>
<br/>
"...SavingChanges (for each<br/>
record)..."<br/>
<br/>
That's the worst thing you can do! Calling SaveChanges() for each record slows bulk inserts extremely down. I would do a few simple tests which will very likely improve the performance:<br/>
<br/>
Call SaveChanges() once after ALL records.<br/>
<br/>
Call SaveChanges() after for example 100 records.<br/>
<br/>
Call SaveChanges() after for example 100 records and dispose the context and create a new one.<br/>
<br/>
Disable change detection<br/>
<br/>
For bulk inserts I am working and experimenting with a pattern like this:<br/>
<br/>
using (TransactionScope scope = new TransactionScope())<br/>
{<br/>
MyDbContext context = null;<br/>
try<br/>
{<br/>
context = new MyDbContext();<br/>
context.Configuration.AutoDetectChangesEnabled = false;<br/>
<br/>
int count = 0; <br/>
foreach (var entityToInsert in someCollectionOfEntitiesToInsert)<br/>
{<br/>
++count;<br/>
context = AddToContext(context, entityToInsert, count, 100, true);<br/>
}<br/>
<br/>
context.SaveChanges();<br/>
}<br/>
finally<br/>
{<br/>
if (context != null)<br/>
context.Dispose();<br/>
}<br/>
<br/>
scope.Complete();<br/>
}<br/>
<br/>
private MyDbContext AddToContext(MyDbContext context,<br/>
Entity entity, int count, int commitCount, bool recreateContext)<br/>
{<br/>
context.Set().Add(entity);<br/>
<br/>
if (count % commitCount == 0)<br/>
{<br/>
context.SaveChanges();<br/>
if (recreateContext)<br/>
{<br/>
context.Dispose();<br/>
context = new MyDbContext();<br/>
context.Configuration.AutoDetectChangesEnabled = false;<br/>
}<br/>
}<br/>
<br/>
return context;<br/>
}<br/>
<br/>
```<br/>
<br/>
I have a test program which inserts 560.000 entities (9 scalar properties, no navigation properties) into the DB. With this code it works in less than 3 minutes.<br/>
<br/>
For the performance it is important to call `SaveChanges()` after "many" records ("many" around 100 or 1000). It also improves the performance to dispose the context after SaveChanges and create a new<br/>
<br/>
*(Réponse tronquée)*</t>