Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DbConfiguration Class

 

A class derived from this class can be placed in the same assembly as a class derived from DbContext to define Entity Framework configuration for an application. Configuration is set by calling protected methods and setting protected properties of this class in the constructor of your derived type. The type to use can also be registered in the config file of the application. See http://go.microsoft.com/fwlink/?LinkId=260883 for more information about Entity Framework configuration.

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

System.Object
  System.Data.Entity.DbConfiguration

public class DbConfiguration

NameDescription
System_CAPS_protmethodDbConfiguration()

Initializes a new instance of the DbConfiguration class.

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticDependencyResolver

Gets the IDbDependencyResolver that is being used to resolve service dependencies in the Entity Framework.

NameDescription
System_CAPS_protmethodAddDefaultResolver(IDbDependencyResolver)

Adds a IDbDependencyResolver instance to the Chain of Responsibility of resolvers that are used to resolve dependencies needed by the Entity Framework.

System_CAPS_protmethodAddDependencyResolver(IDbDependencyResolver)

Adds a IDbDependencyResolver instance to the Chain of Responsibility of resolvers that are used to resolve dependencies needed by the Entity Framework.

System_CAPS_protmethodAddInterceptor(IDbInterceptor)

Registers an IDbInterceptor at application startup. Note that interceptors can also be added and removed at any time using DbInterception.

System_CAPS_pubmethodEquals(Object)

Specifies whether this instance is equal to a specific object.(Overrides Object.Equals(Object).)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Gets the hash code associated with this instance.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.

System_CAPS_pubmethodSystem_CAPS_staticLoadConfiguration(Assembly)

Attempts to discover and load the DbConfiguration from the given assembly. This method is intended to be used by tooling to ensure that the correct configuration is loaded into the app domain. Tooling should use this method before accessing the DependencyResolver property. If the tooling knows the DbContext type being used, then the LoadConfiguration method should be used since it gives a greater chance that the correct configuration will be found.

System_CAPS_pubmethodSystem_CAPS_staticLoadConfiguration(Type)

Attempts to discover and load the DbConfiguration associated with the given DbContext type. This method is intended to be used by tooling to ensure that the correct configuration is loaded into the app domain. Tooling should use this method before accessing the DependencyResolver property.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.

System_CAPS_pubmethodSystem_CAPS_staticSetConfiguration(DbConfiguration)

The Singleton instance of DbConfiguration for this app domain. This can be set at application start before any Entity Framework features have been used and afterwards should be treated as read-only.

System_CAPS_protmethodSetContextFactory(Type, Func<DbContext>)

Call this method from the constructor of a class derived from DbConfiguration to set a factory to allow DbContextInfo to create instances of a context that does not have a public, parameterless constructor.

System_CAPS_protmethodSetContextFactory<TContext>(Func<TContext>)

Call this method from the constructor of a class derived from DbConfiguration to set a factory to allow DbContextInfo to create instances of a context that does not have a public, parameterless constructor.

System_CAPS_protmethodSetDatabaseInitializer<TContext>(IDatabaseInitializer<TContext>)

Call this method from the constructor of a class derived from DbConfiguration to set the database initializer to use for the given context type. The database initializer is called when a the given DbContext type is used to access a database for the first time. The default strategy for Code First contexts is an instance of CreateDatabaseIfNotExists<TContext>.

System_CAPS_protmethodSetDatabaseLogFormatter(Func<DbContext, Action<String>, DatabaseLogFormatter>)

Call this method from the constructor of a class derived from DbConfiguration to set a factory for the type of DatabaseLogFormatter to use with Log.

System_CAPS_protmethodSetDefaultConnectionFactory(IDbConnectionFactory)

Sets the IDbConnectionFactory that is used to create connections by convention if no other connection string or connection is given to or can be discovered by DbContext. Note that a default connection factory is set in the app.config or web.config file whenever the EntityFramework NuGet package is installed. As for all config file settings, the default connection factory set in the config file will take precedence over any setting made with this method. Therefore the setting must be removed from the config file before calling this method will have any effect. Call this method from the constructor of a class derived from DbConfiguration to change the default connection factory being used.

System_CAPS_protmethodSetDefaultHistoryContext(Func<DbConnection, String, HistoryContext>)

Call this method from the constructor of a class derived from DbConfiguration to set a Func<T1, T2, TResult> delegate which which be used for creation of the default HistoryContext for a any DbMigrationsConfiguration. This default factory will only be used if no factory is set explicitly in the DbMigrationsConfiguration and if no factory has been registered for the provider in use using the SetHistoryContext method.

System_CAPS_protmethodSetDefaultSpatialServices(DbSpatialServices)

Call this method from the constructor of a class derived from DbConfiguration to set the global instance of DbSpatialServices which will be used whenever a spatial provider is required and a provider-specific spatial provider cannot be found. Normally, a provider-specific spatial provider is obtained from the a DbProviderServices implementation which is in turn returned by resolving a service for DbSpatialServices passing the provider invariant name as a key. However, this cannot work for stand-alone instances of DbGeometry and DbGeography since it is impossible to know the spatial provider to use. Therefore, when creating stand-alone instances of DbGeometry and DbGeography the global spatial provider is always used.

System_CAPS_protmethodSetDefaultTransactionHandler(Func<TransactionHandler>)

Call this method from the constructor of a class derived from DbConfiguration to register a TransactionHandler.

System_CAPS_protmethodSetExecutionStrategy(String, Func<IDbExecutionStrategy>)

Call this method from the constructor of a class derived from DbConfiguration to register an IDbExecutionStrategy for use with the provider represented by the given invariant name.

System_CAPS_protmethodSetExecutionStrategy(String, Func<IDbExecutionStrategy>, String)

Call this method from the constructor of a class derived from DbConfiguration to register an IDbExecutionStrategy for use with the provider represented by the given invariant name and for a given server name.

System_CAPS_protmethodSetHistoryContext(String, Func<DbConnection, String, HistoryContext>)

Call this method from the constructor of a class derived from DbConfiguration to set a Func<T1, T2, TResult> delegate which allows for creation of a customized HistoryContext for the given provider for any DbMigrationsConfiguration that does not have an explicit factory set.

System_CAPS_protmethodSetManifestTokenResolver(IManifestTokenResolver)

Call this method from the constructor of a class derived from DbConfiguration to set an implementation of IManifestTokenResolver which allows provider manifest tokens to be obtained from connections without necessarily opening the connection.

System_CAPS_protmethodSetMetadataAnnotationSerializer(String, Func<IMetadataAnnotationSerializer>)

Call this method from the constructor of a class derived from DbConfiguration to set a factory for implementations of IMetadataAnnotationSerializer which allows custom annotations represented by MetadataProperty instances to be serialized to and from the EDMX XML.

System_CAPS_protmethodSetMigrationSqlGenerator(String, Func<MigrationSqlGenerator>)

Call this method from the constructor of a class derived from DbConfiguration to register a MigrationSqlGenerator for use with the provider represented by the given invariant name.

System_CAPS_protmethodSetModelCacheKey(Func<DbContext, IDbModelCacheKey>)

Call this method from the constructor of a class derived from DbConfiguration to set a Func<T, TResult> as the model cache key factory which allows the key used to cache the model behind a DbContext to be changed.

System_CAPS_protmethodSetPluralizationService(IPluralizationService)

Call this method from the constructor of a class derived from DbConfiguration to set the pluralization service.

System_CAPS_protmethodSetProviderFactory(String, DbProviderFactory)

Call this method from the constructor of a class derived from DbConfiguration to register an ADO.NET provider.

System_CAPS_protmethodSetProviderFactoryResolver(IDbProviderFactoryResolver)

Call this method from the constructor of a class derived from DbConfiguration to set an implementation of IDbProviderFactoryResolver which allows a DbProviderFactory to be obtained from a DbConnection in cases where the default implementation is not sufficient.

System_CAPS_protmethodSetProviderServices(String, DbProviderServices)

Call this method from the constructor of a class derived from DbConfiguration to register an Entity Framework provider.

System_CAPS_protmethodSetSpatialServices(DbProviderInfo, DbSpatialServices)

Call this method from the constructor of a class derived from DbConfiguration to set an implementation of DbSpatialServices to use for a specific provider and provider manifest token.

System_CAPS_protmethodSetSpatialServices(String, DbSpatialServices)

Call this method from the constructor of a class derived from DbConfiguration to set an implementation of DbSpatialServices to use for a specific provider with any manifest token.

System_CAPS_protmethodSetTableExistenceChecker(String, TableExistenceChecker)

Call this method from the constructor of a class derived from DbConfiguration to register a database table existence checker for a given provider.

System_CAPS_protmethodSetTransactionHandler(String, Func<TransactionHandler>)

Call this method from the constructor of a class derived from DbConfiguration to register a TransactionHandler for use with the provider represented by the given invariant name.

System_CAPS_protmethodSetTransactionHandler(String, Func<TransactionHandler>, String)

Call this method from the constructor of a class derived from DbConfiguration to register a TransactionHandler for use with the provider represented by the given invariant name and for a given server name.

System_CAPS_pubmethodToString()

Returns a string representation of this instance.(Overrides Object.ToString().)

NameDescription
System_CAPS_pubeventSystem_CAPS_staticLoaded

Occurs during EF initialization after the DbConfiguration has been constructed but just before it is locked ready for use.

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:
© 2015 Microsoft