The problem is that the enable-migrations
command appears to have a hard-coded path where EF looks for built DLLs of your project at /bin/Debug
, no matter what the actual build path is. When you change a Project to x64, Visual Studio quietly changes your project's build path to /bin/x64/Debug
- while EF keeps looking in /bin/Debug
. That causes this vague System.BadImageFormatException.
It's harmless to just change your Project build path to /bin/Debug
and magically, everything begins working like it's supposed to.
Bug exists up to and including EF 6.1.0. Bug report posted.
Update: Microsoft has decided not to bother fixing the bug, closed as wontfix, because a workaround exists. Pretty bad behavior.