LocalDbConnectionFactory Class
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.
Instances of this class are used to create DbConnection objects for SQL Server LocalDb based on a given database name or connection string.
public sealed class LocalDbConnectionFactory : System.Data.Entity.Infrastructure.IDbConnectionFactory
type LocalDbConnectionFactory = class
interface IDbConnectionFactory
Public NotInheritable Class LocalDbConnectionFactory
Implements IDbConnectionFactory
- Inheritance
-
LocalDbConnectionFactory
- Implements
Remarks
An instance of this class can be set on the Database class or in the app.config/web.config for the application to cause all DbContexts created with no connection information or just a database name to use SQL Server LocalDb by default. This class is immutable since multiple threads may access instances simultaneously when creating connections.
Constructors
LocalDbConnectionFactory(String, String) |
Creates a new instance of the connection factory for the given version of LocalDb. For SQL Server 2012 LocalDb use "v11.0". For SQL Server 2014 and later LocalDb use "mssqllocaldb". |
LocalDbConnectionFactory(String) |
Creates a new instance of the connection factory for the given version of LocalDb. For SQL Server 2012 LocalDb use "v11.0". For SQL Server 2014 and later LocalDb use "mssqllocaldb". |
Properties
BaseConnectionString |
The connection string to use for options to the database other than the 'Initial Catalog', 'Data Source', and 'AttachDbFilename'. The 'Initial Catalog' and 'AttachDbFilename' will be prepended to this string based on the database name when CreateConnection is called. The 'Data Source' will be set based on the LocalDbVersion argument. The default is 'Integrated Security=True;'. |
Methods
CreateConnection(String) |
Creates a connection for SQL Server LocalDb 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. |
Applies to
Entity Framework