简体   繁体   中英

Entity Framework 7 Core emulate not supported migration operation

I want use user EF 7 + migration + SQLite. But not all operation is supported.

Can I perform not supported operation manually?

Sample I want remove column.

I add new migration with migrationBuilder.DropColumn (SQLite not support DropColumn)

Can I write code for apply migration with skip DropColumn or run my sql instead of

Solution for SQLite with skip DropColumn

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;
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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