Share via


DbConfiguration.SetHistoryContext Method

Definition

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.

protected internal void SetHistoryContext (string providerInvariantName, Func<System.Data.Common.DbConnection,string,System.Data.Entity.Migrations.History.HistoryContext> factory);
member this.SetHistoryContext : string * Func<System.Data.Common.DbConnection, string, System.Data.Entity.Migrations.History.HistoryContext> -> unit
Protected Friend Sub SetHistoryContext (providerInvariantName As String, factory As Func(Of DbConnection, String, HistoryContext))

Parameters

providerInvariantName
String

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

factory
Func<DbConnection,String,HistoryContext>

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

Remarks

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.

Applies to