Enable-migrations命令生成“无法加载文件或程序集...”错误

时间:2015-03-31 00:28:43

标签: asp.net-mvc-5 ef-migrations

我刚刚将我的实体框架从5迁移到6.然后当我试图突然运行Enable-Migrations命令时,我遇到了这些错误:

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or 
assembly 'file:///D:\BitBucketGit\packages\EntityFramework.5.0.0\tools
\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. 
Operation is not supported. 

(Exception from HRESULT: 0x80131515)" At D:\BitBucketGit\packages
\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:5 +     
$utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path 
$ToolsP ... + 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException


You cannot call a method on a null-valued expression.
At D:\BitBucketGit\packages\EntityFramework.6.1.3\tool 
\EntityFramework.psm1:781 char:5
 +     $dispatcher = $utilityAssembly.CreateInstance(

 +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not 
load file or assembly 

'file:///D:\BitBucketGit\packages\EntityFramework.5.0.0\tools
\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is 
 not supported. (Exception from HRESULT: 0x80131515)"
 At D:\BitBucketGit\packages\EntityFramework.6.1.3\tools
 \EntityFramework.psm1:809 char:5

  +     $domain.CreateInstanceFrom(

  +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

  + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

  + FullyQualifiedErrorId : FileLoadException

谷歌搜索后,有人建议完全信任我所做的包文件夹。但错误仍然存​​在。

还有其他方法我可以修复它。

欢呼声,

约翰

2 个答案:

答案 0 :(得分:0)

感谢您的帮助。实际上我只是通过更改devenv.exe.config文件找到了答案。

答案 1 :(得分:0)

由于我从远程服务器中提取项目,因此我通过删除除repositories.config文件以外的所有packages文件夹内容并恢复了所有NuGet包来解决了这个问题。