I am using EF 4 to retrieve a list of Employees.
public ContentResult AutoCompleteResult(string searchText)
{
List list = Employee.GetAll
Thought I would chime in here with my 2 cents. We had a very big data access layer, and one of the programmers was used to using a using statement for the context like so:
using (EntityModel myContext = EntityConnection)
{
//code in here to grab data
}
We are using the EntityConnection as a static property that serves up a dbContext per current HttpContext. Any method called after his using block would throw the exception 'ObjectContext instance has been disposed' since obviously the context was disposed of after his method call. So if you are only using one entity context per HttpContext, make sure you don't allow the garbage collector to dispose of it by using a using block.
I figured I would throw this in the answers since I know a lot of people use the entity context differently and I see a lot of using blocks in code samples out there.