EntityConnection Class

EntityConnection Class

.NET Framework (current version)
 

Contains a reference to a conceptual model and a data source connection. This class cannot be inherited.

Namespace:   System.Data.EntityClient
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Data.Common.DbConnection
        System.Data.EntityClient.EntityConnection

[<Sealed>]
type EntityConnection = 
    class
        inherit DbConnection
    end

NameDescription
System_CAPS_pubmethodEntityConnection()

Initializes a new instance of the EntityConnection class.

System_CAPS_pubmethodEntityConnection(MetadataWorkspace, DbConnection)

Initializes a new instance of the EntityConnection class with a specified MetadataWorkspace and DbConnection.

System_CAPS_pubmethodEntityConnection(String)

Initializes a new instance of the EntityConnection class, based on the connection string.

NameDescription
System_CAPS_pubpropertyConnectionString

Gets or sets the EntityConnection connection string.(Overrides DbConnection.ConnectionString.)

System_CAPS_pubpropertyConnectionTimeout

Gets the number of seconds to wait when attempting to establish a connection before ending the attempt and generating an error.(Overrides DbConnection.ConnectionTimeout.)

System_CAPS_pubpropertyContainer

Gets the IContainer that contains the Component.(Inherited from Component.)

System_CAPS_pubpropertyDatabase

Gets the name of the current database, or the database that will be used after a connection is opened.(Overrides DbConnection.Database.)

System_CAPS_pubpropertyDataSource

Gets the name or network address of the data source to connect to.(Overrides DbConnection.DataSource.)

System_CAPS_pubpropertyServerVersion

Gets a string that contains the version of the data source to which the client is connected.(Overrides DbConnection.ServerVersion.)

System_CAPS_pubpropertySite

Gets or sets the ISite of the Component.(Inherited from Component.)

System_CAPS_pubpropertyState

Gets the ConnectionState property of the underlying provider if the EntityConnection is open. Otherwise, returns Closed.(Overrides DbConnection.State.)

System_CAPS_pubpropertyStoreConnection

Provides access to the underlying data source connection that is used by the EntityConnection object.

NameDescription
System_CAPS_pubmethodBeginTransaction()

Begins a transaction by using the underlying provider.

System_CAPS_pubmethodBeginTransaction(IsolationLevel)

Begins a transaction with the specified isolation level by using the underlying provider.

System_CAPS_pubmethodChangeDatabase(String)

Not supported.(Overrides DbConnection.ChangeDatabase(String).)

System_CAPS_pubmethodClose()

Closes the connection to the database.(Overrides DbConnection.Close().)

System_CAPS_pubmethodCreateCommand()

Creates a new instance of an EntityCommand, with the Connection set to this EntityConnection.

System_CAPS_pubmethodCreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

Releases all resources used by the Component.(Inherited from Component.)

System_CAPS_pubmethodEnlistTransaction(Transaction)

Enlists this EntityConnection in the specified transaction.(Overrides DbConnection.EnlistTransaction(Transaction).)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetMetadataWorkspace()

Returns the MetadataWorkspace associated with this EntityConnection.

System_CAPS_pubmethodGetSchema()

Returns schema information for the data source of this DbConnection.(Inherited from DbConnection.)

System_CAPS_pubmethodGetSchema(String)

Returns schema information for the data source of this DbConnection using the specified string for the schema name.(Inherited from DbConnection.)

System_CAPS_pubmethodGetSchema(String, String[])

Returns schema information for the data source of this DbConnection using the specified string for the schema name and the specified string array for the restriction values.(Inherited from DbConnection.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodOpen()

Establishes a connection to the data source by calling the underlying data provider's Open method.(Overrides DbConnection.Open().)

System_CAPS_pubmethodOpenAsync()

An asynchronous version of Open, which opens a database connection with the settings specified by the ConnectionString. This method invokes the virtual method OpenAsync with CancellationToken.None.(Inherited from DbConnection.)

System_CAPS_pubmethodOpenAsync(CancellationToken)

This is the asynchronous version of Open. Providers should override with an appropriate implementation. The cancellation token can optionally be honored.

The default implementation invokes the synchronous Open call and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellationToken. Exceptions thrown by Open will be communicated via the returned Task Exception property.

Do not invoke other methods and properties of the DbConnection object until the returned Task is complete.(Inherited from DbConnection.)

System_CAPS_pubmethodToString()

Returns a String containing the name of the Component, if any. This method should not be overridden.(Inherited from Component.)

NameDescription
System_CAPS_pubeventDisposed

Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)

System_CAPS_pubeventStateChange

Occurs when the state of the event changes.(Inherited from DbConnection.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.BeginTransaction()

Begins a database transaction.(Inherited from DbConnection.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.BeginTransaction(IsolationLevel)

Begins a database transaction with the specified IsolationLevel value.(Inherited from DbConnection.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.CreateCommand()

Creates and returns a DbCommand object that is associated with the current connection.(Inherited from DbConnection.)

To avoid inadvertently putting objects such as System.Data.Common.CommandTrees and ObjectContext out of sync with their metadata, EntityConnection must lock its metadata. No changes to the connection string are allowed after the metadata is locked. The following are two scenarios in which metadata is locked:

  • The EntityConnection instance is constructed through the default constructor, or through the EntityConnection(String) constructor, which accepts a connection string. In either case the connection string might be changed multiple times before the connection is opened. Calling M:System.Data.EntityClient.EntityConnection.Open() or M:System.Data.EntityClient.EntityConnection.GetMetadataWorkspace() locks the metadata.

  • The EntityConnection instance is constructed through the EntityConnection(MetadataWorkspace, DbConnection) constructor, which accepts a MetadataWorkspace and a DbConnection. In this case, the metadata is locked at construction time. No changes to the connection string are ever allowed.

When metadata is loaded, the EntityConnection verifies that the conceptual model, the storage model, and the mapping file are all present.

For code examples, see Working with EntityClient.

.NET Framework
Available since 3.5

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft