This pertains to a project I am inheriting and cannot change table structure or data access model. I have been asked to optimize the algorithm being used to insert data int
I don't think that you will improve the performance when using Entity framework:
The query
Contains
(like IN
in SQL). Contains
is supported only by .NET 4.0. The data modification
SaveChanges
after each modification. You can call it after foreach loop and it will still work. It will pass all modifications in single transaction The problem is not in algorithm but in the way you process the data and technology used to process the data. Entity framework is not a good choice for data pumps. You should go with these information to your boss because improving performance means more complicated change in your application. It is not your fault and it is not the fault of the programmer who did the application. This is a feature of EF which is not very well known and as I know it is not clearly stated in any MS best practices.