3

I have a project with at least 40 migrations. Trying to build a fresh database gives the following error on one of the migration steps (not the last one):

PM> Update-database -ConfigurationTypeName *******.***.Migrations.Configuration
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201501121145515_LocationParentForeignKey, 201501130944127_Part_PartShipmentDocTypeId_Nullable, 201501130949388_PartShipmentDocType_Actibe_RenameTo_Active, 201501130952331_RequestHead_Add_Closed, 201501150844221_Add_Location_SavedFullName].
Applying explicit migration: 201501121145515_LocationParentForeignKey.
System.FormatException: Invalid length for a Base-64 char array or string.
   at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at System.Data.Entity.Migrations.DbMigration.GetModel(Func`2 modelAccessor)
   at System.Data.Entity.Migrations.DbMigration.GetTargetModel()
   at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
   at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
   at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
   at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
   at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
   at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
   at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Invalid length for a Base-64 char array or string.

There is only one base64 encoded string in every migration, in the resx file at the tag <data name="Target" xml:space="preserve"> Normally this tag contains a base64 string that can be decoded without a problem. (Contains an edmx file gzipped.)

In the failing migration this tag contains a string that cannot be decoded. It says the same as Entity Framework Migrations: Invalid length for a Base-64 char array or string.

I will try to regenerate the base64 string now but I will highly appreciate any help.

VS 12.0.31101.00 Update 4 EF 6.1.2-31219

Community
  • 1
  • 1
Perrier
  • 2,753
  • 5
  • 33
  • 53
  • 1
    Copying the base64 string from the migration resx before the bad one into the bad resx file did the trick. What is the purpose of this encoded edmx in every resx file then? – Perrier Jan 26 '15 at 10:44
  • What resx file? code first doesn't use them. – War Oct 06 '15 at 08:59
  • 1
    Every migration step have a .resx file. – Perrier Oct 06 '15 at 15:56
  • Hmmm ... thx, I hadn't noticed that :) – War Oct 07 '15 at 09:10
  • Did you ever resolve this? Can you remember what you did? – Mark Cooper Aug 18 '20 at 19:22
  • @mark Yes, you can find the solution in my first comment. Try to open the resx file and play with the base64 found int the xml tag I wrote above. Try to decode it and if it is corrupted, try to copy an other one over it from a previous resx. – Perrier Aug 19 '20 at 05:35

0 Answers0