DbConfiguration.SetMigrationSqlGenerator Method

Definition

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.

protected internal void SetMigrationSqlGenerator (string providerInvariantName, Func<System.Data.Entity.Migrations.Sql.MigrationSqlGenerator> sqlGenerator);
member this.SetMigrationSqlGenerator : string * Func<System.Data.Entity.Migrations.Sql.MigrationSqlGenerator> -> unit
Protected Friend Sub SetMigrationSqlGenerator (providerInvariantName As String, sqlGenerator As Func(Of MigrationSqlGenerator))

Parameters

providerInvariantName
String

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

sqlGenerator
Func<MigrationSqlGenerator>

A delegate that returns a new instance of the SQL generator each time it is called.

Remarks

This method is typically used by providers to register an associated SQL generator for Code First Migrations. It is different from setting the generator in the DbMigrationsConfiguration because it allows EF to use the Migrations pipeline to create a database even when there is no Migrations configuration in the project and/or Migrations are not being explicitly used. 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 MigrationSqlGenerator. 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