繁体   English   中英

实体框架7核心模拟不支持的迁移操作

[英]Entity Framework 7 Core emulate not supported migration operation

我想使用用户EF 7 +迁移+ SQLite。 但是并不支持所有操作。

可以手动执行不受支持的操作吗?

我要删除的示例列。

我使用migrationBuilder.DropColumn添加新的迁移(SQLite不支持DropColumn)

我可以编写代码以使用skip DropColumn进行应用迁移还是运行我的sql而不是

跳过DropColumn的SQLite解决方案

public class DB: DbContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.ReplaceService<SqliteMigrationsSqlGenerator, SqliteMigrationsSqlGeneratorExt>();
    }
}

public class SqliteMigrationsSqlGeneratorExt: SqliteMigrationsSqlGenerator
{
    public override IReadOnlyList<MigrationCommand> Generate(IReadOnlyList<MigrationOperation> operations, IModel model = null)
    {
        //Remover DropColumn from operations
        return operations;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM