2
votes

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:Screenshot of the DB

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. Migration table Empty 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
Soooo your question is, now that everything is done and working what you are supposed to do with a database? - Rand Random
@RandRandom no, my question is how to make the migrations work, they are not being commited properly. - Bruno Xavier
Not sure it is supported. See here - Steve Greene
"Unexpected end of command - line 1, column 226." - makes me think that HEX literal - x'012345678.....DEF' got too long and was cut in the middle and the ending part of 28C0B00', CAST(_UTF8'6.1.3-40302' AS VARCHAR(32))) just is not present in the SQL CORE. There are implementation restrictions on maximum script length, maximum statement length or a maximum VARCHAR length limit ( firebirdsql.org/refdocs/langrefupd25-hexbinstrings.html ) and seems you just hit one. The end of the statement seems just got cut off. Ergo - do not use literals, use parameters :-D - Arioch 'The
The only thing I know for sure is that the binary string exceeds implementation limits (that string is 106112 characters, and Firebird 2.5 has a limit 32K for string literals and 64K for the entire query string (Firebird 3 allows for 10MB query strings, although literals are still restricted to 32K). The position 226 from the error is the opening quote of the string literal, hence the unexpected end of command: the parser backtracked to that position before giving up. But again, it might be better to take this to the mailinglist; I haven't seen Jiri on SO in a while. - Mark Rotteveel

1 Answers

2
votes

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.