EntityConnectionStringBuilder Class

EntityConnectionStringBuilder Class

.NET Framework (current version)
 

Provides a simple way to create and manage the contents of connection strings used by the EntityClient.

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

System.Object
  System.Data.Common.DbConnectionStringBuilder
    System.Data.EntityClient.EntityConnectionStringBuilder

public sealed class EntityConnectionStringBuilder : DbConnectionStringBuilder

NameDescription
System_CAPS_pubmethodEntityConnectionStringBuilder()

Initializes a new instance of the EntityConnectionStringBuilder class.

System_CAPS_pubmethodEntityConnectionStringBuilder(String)

Initializes a new instance of the EntityConnectionStringBuilder class using the supplied connection string.

NameDescription
System_CAPS_pubpropertyBrowsableConnectionString

Gets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubpropertyConnectionString

Gets or sets the connection string associated with the DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubpropertyCount

Gets the current number of keys that are contained within the ConnectionString property.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubpropertyIsFixedSize

Gets a value that indicates whether the EntityConnectionStringBuilder has a fixed size.(Overrides DbConnectionStringBuilder.IsFixedSize.)

System_CAPS_pubpropertyIsReadOnly

Gets a value that indicates whether the DbConnectionStringBuilder is read-only.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubpropertyItem[String]

Gets or sets the value associated with the specified key. In C#, this property is the indexer.(Overrides DbConnectionStringBuilder.Item[String].)

System_CAPS_pubpropertyKeys

Gets an ICollection that contains the keys in the EntityConnectionStringBuilder.(Overrides DbConnectionStringBuilder.Keys.)

System_CAPS_pubpropertyMetadata

Gets or sets the metadata locations in the connection string.

System_CAPS_pubpropertyName

Gets or sets the name of a section as defined in a configuration file.

System_CAPS_pubpropertyProvider

Gets or sets the name of the underlying .NET Framework data provider in the connection string.

System_CAPS_pubpropertyProviderConnectionString

Gets or sets the inner, provider-specific connection string.

System_CAPS_pubpropertyValues

Gets an ICollection that contains the values in the DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

NameDescription
System_CAPS_pubmethodAdd(String, Object)

Adds an entry with the specified key and value into the DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodClear()

Clears the contents of the EntityConnectionStringBuilder instance.(Overrides DbConnectionStringBuilder.Clear().)

System_CAPS_protmethodClearPropertyDescriptors()

Clears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodContainsKey(String)

Determines whether the EntityConnectionStringBuilder contains a specific key.(Overrides DbConnectionStringBuilder.ContainsKey(String).)

System_CAPS_pubmethodEquals(Object)

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

System_CAPS_pubmethodEquivalentTo(DbConnectionStringBuilder)

Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodGetHashCode()

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

System_CAPS_pubmethodGetType()

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

System_CAPS_pubmethodRemove(String)

Removes the entry with the specified key from the EntityConnectionStringBuilder instance. (Overrides DbConnectionStringBuilder.Remove(String).)

System_CAPS_pubmethodShouldSerialize(String)

Indicates whether the specified key exists in this DbConnectionStringBuilder instance.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodToString()

Returns the connection string associated with this DbConnectionStringBuilder.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubmethodTryGetValue(String, Object)

Retrieves a value corresponding to the supplied key from this EntityConnectionStringBuilder.(Overrides DbConnectionStringBuilder.TryGetValue(String, Object).)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

Copies the elements of the ICollection to an Array, starting at a particular Array index.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Add(Object, Object)

Adds an element with the provided key and value to the IDictionary object.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Contains(Object)

Determines whether the IDictionary object contains an element with the specified key.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.GetEnumerator()

Returns an IDictionaryEnumerator object for the IDictionary object.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDictionary.Remove(Object)

Removes the element with the specified key from the IDictionary object.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetAttributes()

Returns a collection of custom attributes for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetClassName()

Returns the class name of this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetComponentName()

Returns the name of this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetConverter()

Returns a type converter for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultEvent()

Returns the default event for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetDefaultProperty()

Returns the default property for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEditor(Type)

Returns an editor of the specified type for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents()

Returns the events for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetEvents(Attribute[])

Returns the events for this instance of a component using the specified attribute array as a filter.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties()

Returns the properties for this instance of a component.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetProperties(Attribute[])

Returns the properties for this instance of a component using the attribute array as a filter.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor)

Returns an object that contains the property described by the specified property descriptor.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

Gets a value indicating whether access to the ICollection is synchronized (thread safe).(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

Gets an object that can be used to synchronize access to the ICollection.(Inherited from DbConnectionStringBuilder.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIDictionary.Item[Object]

Gets or sets the element with the specified key.(Inherited from DbConnectionStringBuilder.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

The connection string builder lets developers programmatically create syntactically correct connection strings, and parse and rebuild existing connection strings, by using properties and methods of the class. The connection string builder provides strongly typed properties corresponding to the known keyword/value pairs. Developers who must create connection strings as part of applications can use the EntityConnectionStringBuilder class to build and modify connection strings.

The EntityConnectionStringBuilder performs checks for valid keyword/value pairs, each of which is exposed as a EntityConnectionStringBuilder property value.

System_CAPS_noteNote

The connection string for the underlying data source is supplied by the ProviderConnectionString property. The supplied provider connection string is not checked for valid keyword/value pairs.

The following example demonstrates how to use the EntityConnectionStringBuilder in conjunction with a SqlConnectionStringBuilder.


// Specify the provider name, server and database.
string providerName = "System.Data.SqlClient";
string serverName = ".";
string databaseName = "AdventureWorks";

// Initialize the connection string builder for the
// underlying provider.
SqlConnectionStringBuilder sqlBuilder =
    new SqlConnectionStringBuilder();

// Set the properties for the data source.
sqlBuilder.DataSource = serverName;
sqlBuilder.InitialCatalog = databaseName;
sqlBuilder.IntegratedSecurity = true;

// Build the SqlConnection connection string.
string providerString = sqlBuilder.ToString();

// Initialize the EntityConnectionStringBuilder.
EntityConnectionStringBuilder entityBuilder =
    new EntityConnectionStringBuilder();

//Set the provider name.
entityBuilder.Provider = providerName;

// Set the provider-specific connection string.
entityBuilder.ProviderConnectionString = providerString;

// Set the Metadata location.
entityBuilder.Metadata = @"res://*/AdventureWorksModel.csdl|
                            res://*/AdventureWorksModel.ssdl|
                            res://*/AdventureWorksModel.msl";
Console.WriteLine(entityBuilder.ToString());

using (EntityConnection conn =
    new EntityConnection(entityBuilder.ToString()))
{
    conn.Open();
    Console.WriteLine("Just testing the connection.");
    conn.Close();
}

.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