0
votes

I'm new to using MVC, and when working through the tutorials regarding migrations in Visual Studio 2013 I appear to have broken the tie-in to EntityFramework in the Package Manager console.

I believe this started when I updated the EntityFramework to version 6.1.3, But that appears to be incompatible with the MVC Controller scaffolding. So I rolled it back to version 5.0.0.

When I now enter the command enable-migrations

I get the following error:

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'EntityFramework, Version=5.0.0.0 , Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified." At D:\ss\CAP\CAP_MVC_Dev_2\CAP_MVC\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:431 char:31 + $domain.CreateInstanceFrom <<<< ( + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodTargetInvocation

The file EntityFramework.psm1 exists where it is described above, but the error appears to be in that file? How is $domain.CreateInstanceFrom missing, and where from? Uninstalling and reinstalling the EntityFramework package makes no difference.

I've tried creating new projects from scratch and this error persists across them. An uninstall/reinstall of Visual Studio 2013 has not resolved the issue either, nor has destroying the connected database and starting again with an empty one.

2

2 Answers

2
votes

So, it turns out the solution was similar to this one

Entity Framework code first migrations throwing error

When I first attempted this solution there were reports of gacutil not being recognised. Due to the environment I work it it is not simple to add the gacutil to be universally recognised (I believe), so i found the gacutil.exe in the file system, copied that to the lib\net45 folder referenced in the linked post, and then ran the command

gacutil /i EntityFramework.dll

This has resolved the problem, and i no longer receive the 'File not Found error'

2
votes

Instead of installing with GAC, I came to the following solution (VS2013 SP5 + EF 5):

Copied (Solution dir)\packages\EntityFramework.5.0.0 (entire directory) to

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\EFTools\NuGet Packages\

The NuGet Packages directory did not exist, so one needs to create it manually.