DbConfiguration.SetHistoryContext Method (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.

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

protected internal void SetHistoryContext(
	string providerInvariantName,
	Func<DbConnection, string, HistoryContext> factory
)

Parameters

providerInvariantName
Type: System.String

The invariant name of the ADO.NET provider for which this generator should be used.

factory
Type: System.Func<DbConnection, String, HistoryContext>

A factory for creating HistoryContext instances for a given DbConnection and String representing the default schema.

This method is provided as a convenient and discoverable way to add configuration to the Entity Framework. Internally it works in the same way as using AddDependencyResolver to add an appropriate resolver for Func<T1, T2, TResult>. This means that, if desired, the same functionality can be achieved using a custom resolver or a resolver backed by an Inversion-of-Control container.