我有一个来自SqlServerMigrationSqlGenerator的自定义类。
public class CustomMigration : SqlServerMigrationSqlGenerator
{
protected override void Generate(AlterColumnOperation alterColumnOperation)
{
// ....
// ....
}
}
在方法Generate中是否可以在当前数据库上执行sql命令来应用迁移?例如:
public class CustomMigration : SqlServerMigrationSqlGenerator
{
protected override void Generate(AlterColumnOperation alterColumnOperation)
{
// I need to get the DATABASE CONTEXT HERE!!!
// to execute a sql command
var c = context.Database.ExecuteSqlCommand("SELECT DATABASEPROPERTYEX('MyDB', 'Collation')");
}
}
谢谢!