jac*_*oke 13 asp.net entity-framework ef-migrations visual-studio-2012
我正在尝试在我的Visual Studio Web Express 2012中启用Code First.从我到目前为止所读到的内容,我必须使用Package Manager控制台和命令Enable-Migrations.当我这样做时,我得到以下错误.
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///E:\Working\wingtoysdl\C#\packages\EntityFramework.5
.0.0\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:398 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 E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:399 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:///E:\Working\wingtoysdl\C#\packages\EntityF
ramework.5.0.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
)"
At E:\Working\wingtoysdl\C#\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:431 char:31
+ $domain.CreateInstanceFrom <<<< (
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Run Code Online (Sandbox Code Playgroud)
正如您所看到的那样,这是一个非常大的错误,因此很难进行谷歌和故障排除.有没有人对如何解决这个问题有任何想法?
小智 28
我现在两次遇到这个问题.两次我都必须卸载实体框架,然后为解决方案中的每个项目重新安装它.我花了一段时间来弄清楚我第二次这样做是因为我必须在重新安装Entity Framework之后重新启动Visual Studio(2012)(或者我继续得到"无法加载文件或程序集" [path]\packages\EntityFramework.5 .0.0\tools\EntityFramework.PowerShell.Utility.dll'"错误).
要访问Package Manager控制台,请转到:工具 - >库包管理器 - >包管理器控制台
在Package Manager中卸载每个项目的Entity Framework(我从Package Manager控制台顶部的Default Project下拉列表中选择了每个项目):
Uninstall-Package EntityFramework -Force
然后为每个项目安装它:
Install-Package EntityFramework
此时,尝试运行Enable-Migrations命令仍然出现错误,直到我关闭并重新启动Visual Studio.然后它就成功了,就像Update-Database命令一样(在Migrations.Configuration文件中将AutomaticMigrationsEnabled设置为true之后).
| 归档时间: |
|
| 查看次数: |
14697 次 |
| 最近记录: |