EntityConnection.GetMetadataWorkspace Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Important
This API is not CLS-compliant.
Returns the MetadataWorkspace associated with this EntityConnection.
public:
System::Data::Metadata::Edm::MetadataWorkspace ^ GetMetadataWorkspace();
public System.Data.Metadata.Edm.MetadataWorkspace GetMetadataWorkspace ();
[System.CLSCompliant(false)]
public System.Data.Metadata.Edm.MetadataWorkspace GetMetadataWorkspace ();
member this.GetMetadataWorkspace : unit -> System.Data.Metadata.Edm.MetadataWorkspace
[<System.CLSCompliant(false)>]
member this.GetMetadataWorkspace : unit -> System.Data.Metadata.Edm.MetadataWorkspace
Public Function GetMetadataWorkspace () As MetadataWorkspace
Returns
The MetadataWorkspace associated with this EntityConnection.
- Attributes
Exceptions
The inline connection string contains an invalid Metadata
keyword value.
Remarks
A MetadataWorkspace is automatically created when the EntityConnection class is created. The creation process might throw metadata-specific exceptions. Metadata is loaded into memory and an Entity Data Model (EDM) application uses that metadata to access information about the underlying data source. For more information, see ADO.NET Metadata.
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 parameterless constructor, or through the EntityConnection(String) constructor, which accepts a connection string. In either case the connection string may be changed multiple times before the connection is opened. Open or 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.