本文介绍了启用迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的EF,当我尝试在PMC控制台中运行启用迁移时,我有一个错误:
异常调用LoadFrom与1参数:

 无法加载文件或程序集file:///...\pa 
ckages\EntityFramework.6.0.1\\ \\tools\EntityFramework.PowerShell.Utility.dll'或其一个依赖关系不支持操作(来自HRESULT的异常:0x80131515)
在... \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



您无法调用空值表达式的方法。
在... \packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:781 char:50
+ $ dispatcher = $ utilityAssembly.CreateInstance<<<<< ; (
+ CategoryInfo:InvalidOperation:(CreateInstance:String)[],RuntimeException
+ FullyQualifiedErrorId:InvokeMethodOnNull

使用8参数调用CreateInstanceFrom异常:无法加载文件或程序集file:///...\packages\EntityFramework.6.0.1\tools\EntityFramework.PowerShell.dll或其依赖项之一,不支持操作(异常来自HRESULT:0x80131515)
At ... \packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:809 char:31
+ $ domain.CreateInstanceFrom<< <(
+ CategoryInfo:NotSpecified:(:) [],MethodInvocationException
+ FullyQualifiedErrorId:DotNetMethodException


解决方案

我刚刚在同事的一台机器上碰到这个问题,解决方法是:


  1. 卸载EF NuGet软件包

  2. 手动删除实体框Web.Config / App.Config文件中的ework部分

  3. 关闭Visual Studio

  4. 在Visual Studio中重新打开解决方案

  5. 重新安装EF NuGet软件包


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
解决方案

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

这篇关于启用迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 12:32