实体框架代码第一次迁移和Firebird

时间:2017-05-30 15:21:21

标签: c# entity-framework ef-code-first firebird

我正在尝试在Firebird 2.5数据库上启用迁移。

我正在使用VS2015并且ADO驱动程序和实体提供程序已安装并正常运行。

我对数据库进行了逆向工程,进行了必要的更改以使其正常工作。

我可以在程序包管理器控制台上执行启用迁移,并添加迁移。

当我更新数据库时会发生这种情况:

PM> update-database 
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201705301505265_Initial].
Applying explicit migration: 201705301505265_Initial.

ScriptHalted

如果我做了更新数据库-Verbose,我得到了这个:

PM> update-database -Verbose
Using StartUp project 'Visao.Web'.
Using NuGet project 'Visao.Data'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'D:\Upwork\Fernando\SIGECOM.FDB' (DataSource: localhost, Provider: FirebirdSql.Data.FirebirdClient, Origin: Configuration).
Applying explicit migrations: [201705301505265_Initial].
Applying explicit migration: 201705301505265_Initial.
INSERT INTO "__MigrationHistory"("MigrationId", "ContextKey", "Model", "ProductVersion")
VALUES (CAST(_UTF8'201705301505265_Initial' AS VARCHAR(150)), CAST(_UTF8'Visao.Data.Migrations.Configuration' AS VARCHAR(300)), x'1F8B0800000000000400ECBDDD92DC3

和很多角色,因为它试图将blob添加到数据库中。

__MigrationHistory数据库已添加到FDB文件中:Screenshot of the DB

所以我猜它有点工作。

我不知道接下来要做什么,有人吗?

修改

由于似乎一切都已创建,我认为错误可能来自迁移表上的Insert。 Migration table Empty 也许是一个错误?

编辑2

created an SQL script使用Update-Database -Script并尝试在IBExplorer上运行并收到以下错误:

can't format message 13:896 -- message file C:\WINDOWS\firebird.msg not found.
Dynamic SQL Error.
SQL error code = -104.
Unexpected end of command - line 1, column 226.

即使仅运行Insert语句也无效。

编辑3

在其跟踪器中创建issue以查看其他人是否知道

编辑4

似乎负责Bug Tracker页面的人不断删除错误。

无论如何,如果我更改了MSSQL或MySQL的提供程序,迁移就会起作用。

编辑5

这是第一次创建的迁移。它是空的,因为我正在尝试使用已填充的现有数据库,现在我想使用Code First。

public partial class Initial : DbMigration
    {
        public override void Up()
        {
        }

        public override void Down()
        {
        }
    }

1 个答案:

答案 0 :(得分:2)

正如Mark Rotteveel所说(他应该得到这个答案的分数)。您在Firebird中达到了语句大小的限制。我用它做的不多,因为这需要是脚本(即使它是直接执行的),所以参数不会起作用。

可能的解决方法是创建多个较小的模型并将其用于迁移。或者始终将脚本生成到文件中并手动使用参数。