问题
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()
{
}
}
回答1:
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.
来源:https://stackoverflow.com/questions/44266141/entity-framework-code-first-migrations-and-firebird