views:

691

answers:

2

I cannot find any examples on how to do a Bulk/batch insert using Linq to Entities. Do you guys know how to do a Bulk Insert?

+1  A: 
  1. You can't do any kind of insert in LINQ-to-anything. LINQ doesn't do inserts.
  2. The EF doesn't do bulk inserts per se.
  3. You can however insert multiple records in a single transaction by only calling SaveChanges once.

It would be easier to help you with your problem if you explained what you're trying to do in much more detail.

Craig Stuntz
+1  A: 

Sometimes you simply have to mix models. Perhaps use SqlBulkCopy for this part of your repository (since this plugs directly into the bulk-copy API), and Entity Framework for some of the rest. And if necessary, a bit of direct ADO.NET. Ultimately the goal is to get the job done.

Marc Gravell