Ninject & Entity Framework =(sometimes) "The ObjectContext instance has been disposed ..."
- by n26
I am using Ninject and ADO.Net Entity Framework in my Aps.Net (Mvc) website. I bind the ObjectContext to Ninject using the RequestScope:
Bind<Entities>().ToSelf().InRequestScope().WithConstructorArgument("connectionString", _connectionString);
In most cases this works perferct. But sometimes I got the following error:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
This error occurs at different positions while getting, updating, inserting or deleting data. In some cases this error occurs until I reset my webapp and sometimes it disappears after some requests.
I am displeased that I have no more details. Because it seems that there is no pattern when and where this error occurs. Because the time and position is allways different :(
Some hints or ideas?