SqlCeConnectionFactory Class

Definition

Instances of this class are used to create DbConnection objects for SQL Server Compact Edition based on a given database name or connection string.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", Justification="Casing is intentional")]
public sealed class SqlCeConnectionFactory : System.Data.Entity.Infrastructure.IDbConnectionFactory
public sealed class SqlCeConnectionFactory : System.Data.Entity.Infrastructure.IDbConnectionFactory
type SqlCeConnectionFactory = class
    interface IDbConnectionFactory
Public NotInheritable Class SqlCeConnectionFactory
Implements IDbConnectionFactory
Inheritance
SqlCeConnectionFactory
Attributes
Implements

Remarks

It is necessary to provide the provider invariant name of the SQL Server Compact Edition to use when creating an instance of this class. This is because different versions of SQL Server Compact Editions use different invariant names. An instance of this class can be set on the Database class to cause all DbContexts created with no connection information or just a database name or connection string to use SQL Server Compact Edition by default. This class is immutable since multiple threads may access instances simultaneously when creating connections.

Constructors

SqlCeConnectionFactory(String, String, String)

Creates a new connection factory with the given DatabaseDirectory and BaseConnectionString properties.

SqlCeConnectionFactory(String)

Creates a new connection factory with empty (default) DatabaseDirectory and BaseConnectionString properties.

Properties

BaseConnectionString

The connection string to use for options to the database other than the 'Data Source'. The Data Source will be prepended to this string based on the database name when CreateConnection is called. The default is the empty string, which means no other options will be used.

DatabaseDirectory

The path to prepend to the database name that will form the file name used by SQL Server Compact Edition when it creates or reads the database file. The default value is "|DataDirectory|", which means the file will be placed in the designated data directory.

ProviderInvariantName

The provider invariant name that specifies the version of SQL Server Compact Edition that should be used.

Methods

CreateConnection(String)

Creates a connection for SQL Server Compact Edition 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