In my application I receive the following error:
The context cannot be used while the model is being created.
I\'m not sure what
I had the same issue and solved it using following code:
Database.SetInitializer<EntitiesName>(null);
I had this error as well but was able to solve it by declaring a local variable context inside of each thread rather than using the one I had declared globally.
Parallel.ForEach(myList, l=>
{
MyContext _db = new MyContext();
// do some stuff....
_db.Model.Add(....);
_db.SaveChanges();
});
Make sure you also set MultipleActiveResultSets=true in your connection string as described above.