Data Access has been discontinued. Please refer to this page for more information.

Managing Instances of the OpenAccessContext Class - Overview

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

The topics in this section show how to manage the OpenAccessContext.

Creating a New Instance of the OpenAccessContext

Before you start using the OpenAccessContext in your application, you should initialize it. The most straightforward way to do that is to use the default constructor.

EntitiesModel dbContext = new EntitiesModel();
Dim dbContext As New EntitiesModel()

Disposing an OpenAccessContext

Once a new instance of the OpenAccessContext has been created, a new connection to the database is also created. The connection is closed when the OpenAccessContext is disposed. The OpenAccessContext implements the IDisposable interface, thus it provides a Dispose() method and could be used inside a using statement.

EntitiesModel dbContext = new EntitiesModel();
dbContext.Dispose();

// -or-

using ( EntitiesModel dbContext = new EntitiesModel() )
{
}
Dim dbContext As New EntitiesModel()
dbContext.Dispose()
' -Or-
Using dbContext As New EntitiesModel()
End Using

In this section: