启用 - 迁移时出错

use*_*462 6 .net c# entity-framework asp.net-mvc-4

我是EF的新手,当我尝试在PMC控制台中运行Enable-Migrations时出现错误:使用"1"参数调用"LoadFrom"的异常:

 "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
Run Code Online (Sandbox Code Playgroud)

DVK*_*DVK 7

我刚刚在同事的机器上碰到了这个.解决方案是:

  1. 卸载EF NuGet包
  2. 从Web.Config/App.Config文件中手动删除实体框架部分
  3. 关闭Visual Studio
  4. 在Visual Studio中重新打开解决方案
  5. 重新安装EF NuGet包


anI*_*Mer 3

因此,在文件资源管理器中打开解决方案文件夹,您能否在“Packages”文件夹中找到他们正在寻找的.dll,然后在EntityFramework 6.0.1文件夹中找到它们?如果没有,有两种选择:

  1. 检查您的源代码控制服务器,有可能它没有下载到本地工作区。如果是这样,如果您使用的是 TFS,只需从源代码管理资源管理器手动获取它们。
  2. 如果这些文件也不在源代码管理服务器上,我建议卸载 EF 6.0.1 nuget,然后手动删除上面 Package 文件夹中有关 ef 的整个文件夹,然后重新安装。