Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SqlConnectionFactory Class

Entity Framework 5.0

Instances of this class are used to create DbConnection objects for SQL Server based on a given database name or connection string. By default, the connection is made to '.\SQLEXPRESS'. This can be changed by changing the base connection string when constructing a factory instance.

System.Object
  System.Data.Entity.Infrastructure.SqlConnectionFactory

Namespace:  System.Data.Entity.Infrastructure
Assembly:  EntityFramework (in EntityFramework.dll)
public sealed class SqlConnectionFactory : IDbConnectionFactory

The SqlConnectionFactory type exposes the following members.

  NameDescription
Public methodSqlConnectionFactory()Creates a new connection factory with a default BaseConnectionString property of 'Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True'.
Public methodSqlConnectionFactory(String)Creates a new connection factory with the given BaseConnectionString property.
Top
  NameDescription
Public propertyBaseConnectionStringThe connection string to use for options to the database other than the 'Initial Catalog'. The 'Initial Catalog' will be prepended to this string based on the database name when CreateConnection is called. The default is 'Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True'.
Top
  NameDescription
Public methodCreateConnectionCreates a connection for SQL Server based on the given database name or connection string. If the given string contains an '=' character then it is treated as a full connection string, otherwise it is treated as a database name only.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

An instance of this class can be set on the Database class to cause all DbContext objects to be created with no connection information or just a database name or connection string to use SQL Server by default. This class is immutable since multiple threads may access instances simultaneously when creating connections.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.