How to do a Bulk Insert -- Linq to Entities

asp.net-mvc c# entity-framework linq-to-entities

Question

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
36
10/22/2009 6:35:25 PM

Accepted Answer

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.

22
10/22/2009 9:19:19 PM

Popular Answer

For a perfect example of how to do bulk inserts with LINQ to Entities, see http://archive.msdn.microsoft.com/LinqEntityDataReader. It is a wrapper that allows easy use of SqlBulkCopy.

@Marc Gravell is correct, sometimes you have to mix models to get the job done.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow