实体框架代码首次迁移和Firebird [英] Entity Framework Code First Migrations and Firebird

查看:682
本文介绍了实体框架代码首次迁移和Firebird的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我使用VS2015,ADO驱动程序和实体提供程序已安装并正常工作。 / p>

我反向设计了数据库,进行了必要的更改,使其工作。



我可以做enable-在包管理器控制台上进行迁移,并添加迁移。



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

  PM> update-database 
指定-Verbose标志来查看应用于目标数据库的SQL语句。
应用显式迁移:[201705301505265_Initial]。
应用显式迁移:201705301505265_Initial。

ScriptHalted

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

  PM> update-database -Verbose 
使用StartUp项目'Visao.Web'。
使用NuGet项目'Visao.Data'。
指定'-Verbose'标志来查看应用于目标数据库的SQL语句。
目标数据库是:'D:\Upwork\Fernando\SIGECOM.FDB'(DataSource:localhost,Provider:FirebirdSql.Data.FirebirdClient,Origin:Configuration)。
应用显式迁移:[201705301505265_Initial]。
应用显式迁移: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'1F8B0800000000000400ECBDDDDCDCDC

和很多字符,因为它尝试向数据库添加一个blob。



__MigrationHistory数据库已添加到FDB文件中:



所以我想这是一种工作。



我不知道下一步该做什么? p>

编辑



由于一切似乎都被创建,我认为错误可能来自

也许是一个错误?



编辑2



使用Update-Database -Script创建了一个SQL脚本,并尝试在IBExplorer上运行并得到以下错误:

 不能格式化消息13:896  - 消息文件C:\找不到WINDOWS\firebird.msg 
动态SQL错误。
SQL错误代码= -104。
意外的命令结束 - 第1行,列226.

甚至只运行Insert语句没有工作。



编辑3



创建一个问题在他们的跟踪器中查看是否有人知道



编辑4



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



无论如何,如果我更改提供程序,MSSQL或MySQL,迁移工作。



编辑5



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

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

public override void Down()
{
}
}


解决方案

马克·罗特韦尔(Mark Rotteveel)说(他应该得到这个答案的分数)。您正在Firebird中的语句大小达到极限。我没有太多的工作,因为这需要脚本(即使它是直接执行),所以参数将不起作用。



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


I'm trying to enable migrations on a Firebird 2.5 database.

I'm using VS2015 and the ADO Driver and Entity Provider are installed and working correctly.

I reverse engineered the database, made the necessary changes to make it work.

I can do the enable-migrations on the Package Manager Console, and add a migration.

When I do update-database this happens:

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

If I do a update-database -Verbose I get this:

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

and a lot of character because its trying to add a blob to the database.

The __MigrationHistory database was added to the FDB file:

So I guess it's kind of working.

I have no idea what to do next, anyone?

EDIT

Since everything seems to be created, I think the error might be from the Insert on the Migration Table. Maybe a bug?

EDIT 2

I created an SQL script with Update-Database -Script and tried to run on IBExplorer and get the following error:

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.

Even running just the Insert statement is not working.

EDIT 3

Create an issue in their tracker to see if someone else knows

EDIT 4

It seems that the guys responsible for the Bug Tracker page keeps removing the bug.

Anyway, if I change providers, either MSSQL or MySQL, the migrations works.

EDIT 5

This is the first migration created. It is empty because I'm trying to use an existing database, already populated, and now I want to use Code First.

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

        public override void Down()
        {
        }
    }

解决方案

As Mark Rotteveel said (and he should get points for this answer). You're hitting the limit for a statement size in Firebird. There's not much I can do with it because this needs to be script (even if it's executed directly), so parameters won't work.

Possible workaround would be to create multiple smaller models and use these for migrations. Or always generate the script into file and manually use parameters.

这篇关于实体框架代码首次迁移和Firebird的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆