1

There are MANY MANY posts on the same issue.

The issue: I am developing a C# Console Application with Entity Framework 6.1.3. Code-First.

Until last week, I was running on my Windows 7 machine and VS 2013, and I was doing add-migrations just fine.

Now I have a new machine (Lenovo), running Visual Studio 2015 Community edition on a x64 Windows 10 machine. I can no longer add-migration (on the same code-base... clean github clone).

Running add-migration from the PM console yields the following error:

PM> add-migration test2

System.BadImageFormatException: Could not load file or assembly 'XXXX' or one of its dependencies. An attempt was made to load a program with an incorrect format. File name: 'XXXX' at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) ...

I have several projects in this solution. I have confirmed:

1) Properties of all projects show x64.

2) They all target .NET 4.5

3) Build > Configuration Manager shows all are "Any CPU".

4) Checked Tools > Options > Builds and found nothing related to x86 builds.

5) Search Windows Explorer for the text "x86" ANYWHERE in my tree. Nothing found.

All posts (and there are many of them) on this subject point to the issue being that some file is being compile as 32 bit whereas the startup project is 64. I'm not sure where else to check that this is not my issue other than the properties of all the projects in my solution. So I can't help but think that there is some other setting in this new VS2015 Community edition that I am not seeing?

The solution compiles with no error and runs but I cannot add-migration.

Any help would be truly appreciated. I've spent a day on this. I've tried editing the registry to add keys the Fusion to enable more logging and restarted VS but I did not see any change in logging.

Thanks -Ed

Ed Landau
  • 966
  • 2
  • 11
  • 24
  • First thing I would try is deleting your solution settings (.suo file). Also, remove EF nuget package and re-add. – Steve Greene Jul 08 '16 at 20:07
  • Thanks for trying. I removed .suo (which VS2015 has now moved to a sub-directory), removed EF, reinstalled (all the while restarting VS at every step). Same error. :( – Ed Landau Jul 08 '16 at 20:22
  • You see this? My issue was Oracle bitness. http://stackoverflow.com/questions/8996653/troubleshooting-badimageformatexception – Steve Greene Jul 08 '16 at 20:40
  • Yes, I have see it and I have confirmed that the startup project is targeting x64. I'm doing this by right-clicking on the project and selecting Properties > Build. Is there another way? – Ed Landau Jul 08 '16 at 21:02

0 Answers0