Exception raised when I'm trying enable migrations in EF 4.3.1

痴心易碎 提交于 2019-12-01 03:32:10

I solved problem described above.

  1. I uninstalled Entity framework using NuGet package manager.
  2. I manually cleared subdirectories started with "Entity" in packages directory.
  3. I installed Entity Framework 4.3.1 again

Now migrations are enabled correctly.

I know this is an old question and already has an accepted answer, but I had this issue and thought I'd share what I did to resolve it.


My solution was in source control and I had messed up my local project. I decided to start over from Source Control, so I created a new folder and Checked out the code from SVN.

When I did, I was no longer able to create migrations. I got the same error listed above. I tried Uninstall-Package EntityFramework, but got a similar message about missing files/references within EntityFramework.

I went back to my old folder and looked in $Project\packages\EntityFramework.6.0.2\ and compared this to my new folder. There were several DLLs/Xml files missing because they were not in Source Control. They were in the \tools\ , \lib\net40 and \lib\net45\ directories.

I just copied these files to my new project, closed/reopened Visual Studio, and did a Rebuild. After that, everything was working fine.

Reinstalling the NuGet package didn't work for me. What did work was to move the project from a network drive to a local drive. Running a compare showed that, apart from obj and bin directories, all files were binary identical.

If I remember correctly, my last attempt at Update-Database was before I moved the project to a network drive.

I experiencing this problem when sharing a project with a college by sending him the project. When he sent it back to me I discovered the returned project gave me this error when I tried to add a migration. I solved the problem by over-writing the packages\EntityFramework.5.0.0 folder from the returned project with the folder from my original project.

I don't get the problem if I just move the project about on my own machine.

This problem started happening to me when using different VM's on the same physical machine.

VMWare Fusion defaults to share the profiles directory with OS X, which in turn creates a lot of problems when using multiple VMs with Visual Studio installed, actually almost every application I had installed begun to behave strangely. Should have rung a bell at that time.

The problem was resolved by turning off Folder Sharing, which is not so obvious since I hadn't the option to not share the profile folder, only add/remove other folders.

Hope my stupidity helped someone else out there :)

I have the same problem with projects from Visual Studio 2015 that was open on Visual Studio 2017. Here's how I solved it:

  1. Manually remove Entity Framework from Tools -> NuGet Package Manager -> Manage NuGet Packages From Solution
  2. Search for Entity Framework.
  3. Unfortunately, there are dependencies. So forcing to remove only Entity Framework doesn't solve the problem at all. So whatever the dependencies are, manually remove it from the steps above.
  4. Lastly install again Entity Framework and whatever dependencies that you might have removed. Upon completing this, I didn't restart my Visual Studio, upon typing enable-migrations, everything worked fine already.

To share my experience as well, I tried this step:

Uninstall-Package EntityFramework -Force

Then install it for each project:

Install-Package EntityFramework

But didn't worked on my part. So I guessed I had to manually uninstall it including its dependencies without using force and install it again to work. But glad it did.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!