DbConfiguration.SetMigrationSqlGenerator 方法

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

从派生自 DbConfiguration 的类的构造函数调用此方法,以注册要用于给定固定名称所表示的提供程序的 MigrationSqlGenerator

命名空间:  System.Data.Entity
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
Protected Friend Sub SetMigrationSqlGenerator ( _
    providerInvariantName As String, _
    sqlGenerator As Func(Of MigrationSqlGenerator) _
)
用法
Dim providerInvariantName As String 
Dim sqlGenerator As Func(Of MigrationSqlGenerator)

Me.SetMigrationSqlGenerator(providerInvariantName, _
    sqlGenerator)
protected internal void SetMigrationSqlGenerator(
    string providerInvariantName,
    Func<MigrationSqlGenerator> sqlGenerator
)
protected public:
void SetMigrationSqlGenerator(
    String^ providerInvariantName, 
    Func<MigrationSqlGenerator^>^ sqlGenerator
)
member SetMigrationSqlGenerator : 
        providerInvariantName:string * 
        sqlGenerator:Func<MigrationSqlGenerator> -> unit
function SetMigrationSqlGenerator(
    providerInvariantName : String, 
    sqlGenerator : Func<MigrationSqlGenerator>
)

参数

  • providerInvariantName
    类型:System.String
    此生成器应该用于的 ADO.NET 提供程序的固定名称。

备注

此方法通常由提供程序用来注册 Code First 迁移的关联的 SQL 生成器。 此方法不同于在 DbMigrationsConfiguration 中设置生成器,因为它允许 EF 使用迁移管道创建数据库,甚至在项目中没有迁移配置和/或未在显式使用迁移时也允许。 此方法作为用于将配置添加到实体框架的方便且可发现的方式提供。 在内部,其工作方式与使用 AddDependencyResolver 为 MigrationSqlGenerator 添加适当解析程序的工作方式相同。 这意味着,如果需要,可以使用自定义解析程序或者控制反转容器支持的解析程序实现相同功能。

请参阅

参考

DbConfiguration 类

System.Data.Entity 命名空间