Why is Entity Framework 6.1.3 throwing a "Could not load type 'System.Data.Entity.Infrastructure.TableExistenceChecker'"

If you find as I did that EF is not installed in the Gac then the next step is to uninstall it AFTER you note the version of your package. I use NuGet so I went to Tools...Library Package Manager...Package Manager Console. I tried the GUI first but uninstalling failed and as of this writing you can only install the latest version of the package.

  1. Open your solution and go to Tools...Library Package Manager...Package Manager Console
  2. Select the project that uses EF and is having the problem
  3. Type Uninstall-package EntityFramework
  4. You should be prompted to restart Visual Studio so close and reopen VS and your solution
  5. Open Package Manager Console with Tools...Library Package Manager...Package Manager Console
  6. Type Install-package EntityFramework (add -Version x.x.x if you're installing an older version)
  7. You should be good to go

I had the exact same problem in my unit test project. After a couple of hours of troubleshooting I noticed that the .csproj-file still had reference to my previous version of EF:

<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
</Reference>

I simply changed the version to 6.1.3 and all tests ran fine again.


Apparently if there is a reference to entity framework in the GAC and it is not the same as the one you have referenced via Nuget you get this error. In my case it was 6.0.0 in the GAC.

Solution:

Launch the developer command prompt for visual studio then:

gacutil -u EntityFramework