I'm trying to run a no tracking query on my entities so that I can update them outside of the context. However, when the no tracking is not working and I get an exception stating
"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."
This exception is thrown by a property which in terms of the database model is a foreign key to a separate table, do I need to somehow set notracking for this separate entity as well?
My code is:
List<EmailQueue> result = null;
using (Entities context = new Entities())
{
var emailQueueQuery = context.EmailQueues;
emailQueueQuery.MergeOption = System.Data.Objects.MergeOption.NoTracking;
result = emailQueueQuery.Execute(System.Data.Objects.MergeOption.NoTracking).ToList<EmailQueue>();
}
return result;