Thursday, May 19, 2011

Entity Framework: The ObjectContext instance has been disposed and can no longer be used for operations that require a connection

I had a piece of sequential code that executed in its own task (PFX). This was a sequential foreach loop. I changed this foreach to Parallel.Foreach and my code bombed. I do not think that the issue had anything to do with me trying to execute the foreach loop on all the cores at once. The actual problem was that I was retuning a value from within a using statement and EF did not like it.

Once the removed the return value from my method outside the using statement all is well.

No comments:

Post a Comment