How to: Manage the Connection in a Long-Running Object Context

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This topic provides an example of how to manually open a connection for a long-running object context. The example also shows how to ensure that the connection is released by calling Dispose on the context.

The example in this topic is based on the AdventureWorks Sales Model. To run the code in this example, you must have already added the AdventureWorks Sales Model to your project and configured your project to use the Entity Framework. To do this, complete the procedure in How to: Use the Entity Data Model Wizard.


This example manually opens the connection used by a long-running ObjectContext, then executes a query and saves the changes. The connection is closed when the ObjectContext is disposed.

See Also