Error on Enable-Migrations

6

I'm new with EF and I have an error when I try to run Enable-Migrations in PMC console : Exception calling "LoadFrom" with "1" argument(s):

 "Could not load file or assembly 'file:///...\pa
ckages\EntityFramework.6.0.1\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
At ...\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:780 char:62
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll))
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException



You cannot call a method on a null-valued expression.
At ...\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:781 char:50
+     $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo          : InvalidOperation: (CreateInstance:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///...\packages\EntityFramework.6.0.1\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is no t supported. (Exception from HRESULT: 0x80131515)"
At ...\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:809 char:31
+     $domain.CreateInstanceFrom <<<< (
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
c#
.net
entity-framework
asp.net-mvc-4
asked on Stack Overflow Aug 12, 2014 by user3933462 • edited Aug 12, 2014 by Kartikeya Khosla

5 Answers

9

I just ran into this on one of my co-worker's machine. The solution was:

  1. Uninstall EF NuGet package
  2. Manually remove Entity Framework sections from the Web.Config/App.Config files
  3. Close Visual Studio
  4. Re-open the solution in Visual Studio
  5. Reinstall the EF NuGet Package
answered on Stack Overflow Feb 10, 2016 by DVK
3

So openn the solution folder in file explorer, can you find the .dlls they are looking for in "Packages" folder then EntityFramework 6.0.1 folder? If not, there are two options:

  1. Check your source control server, there is a possibility it was not downloaded to local workspace. if so, just get them manually from source control explorer if you are using TFS.
  2. If the files were not on source control server either, I would recommend to uninstall EF 6.0.1 nuget, then manual delete the whole folder about ef in the Package folder above, and then reinstall it.
answered on Stack Overflow Aug 13, 2014 by anIBMer
1

I had the same problem. My project was stored in a network drive. There are many security policies applied to my PC. I moved my project to the local hard drive, and the problem was solved.

It seems like "EntityFramework.Powershell.utility.dll" is tring to use some powershell functionality, and the system is preventing to execute such calls, maybe because the dll that is calling powershell is not a local file.

In your case, make sure that you do not have any security policy or system configuration that would prevent your system execute the problematical extension from a non local drive (EntityFramework.Powershell.utility.dll)

answered on Stack Overflow May 26, 2015 by Rafa Sanchez
1

Faced similar problem. Reason of the problem was shifting of my code from one machine to another...Removing and then reinstalling entity framework solved the problem.

answered on Stack Overflow Mar 1, 2017 by Anwer Mehmood
0

Update the Entity Package from Package Manager Console or browser.

answered on Stack Overflow Dec 15, 2017 by Sooraj Panda

User contributions licensed under CC BY-SA 3.0