BadImageException с использованием базы данных обновлений

У меня есть сборка с миграциями EF 5.0 (целевая платформа 4.0).

Когда я открываю консоль управления пакетами и набираю «база данных обновления», я получаю исключение BadImageException. (примечание: у меня есть одна нативная библиотека С++ в решении).

Я прочитал несколько сообщений об этом, и я попробовал:

  1. Все проекты имеют целевую платформу x64
  2. Платформа решения — x64, все проекты имеют конфигурацию x64.
  3. Нет предупреждений во время сборки

Но... когда я добавил консольное приложение, используя класс DBMigrator, миграция работает нормально!

Что случается ?

(обновление)

Кажется, что при использовании консоли управления пакетами и использовании «обновления базы данных» он использует .exe в корневом каталоге пакета EF/tools, который называется «migrate.exe». Этот .exe 32-битный и не может загружать 64-битные сборки! Проверьте http://msdn.microsoft.com/en-us/data/jj618307.aspx)

Использование VS2013, обновление 1.

Детали исключения:

PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.BadImageFormatException: Could not load file or assembly 'Progis.Kim.DataAccess.Systeem' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'Progis.Kim.DataAccess.Systeem'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindType[TBase](String typeName, Func`2 filter, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Progis.Kim.DataAccess.Systeem
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Progis.Kim.DataAccess.Systeem | Domain ID: 28
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/WS/ProgisKIM/Development/Progis/Progis.Kim.DataAccess.Systeem/bin/x64/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\WS\ProgisKIM\Development\Progis\Progis.Kim.DataAccess.Systeem\tmpEC23.tmp
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/WS/ProgisKIM/Development/Progis/Progis.Kim.DataAccess.Systeem/bin/x64/Debug/Progis.Kim.DataAccess.Systeem.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Could not load file or assembly 'Progis.Kim.DataAccess.Systeem' or one of its dependencies. An attempt was made to load a program with an incorrect format.
PM> 

person Patrick Peters    schedule 12.02.2014    source источник
comment
Обратите внимание: «Диспетчер сборок загружен из: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll». Разве это не должно быть «C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll»?   -  person Patrick Peters    schedule 12.02.2014