运行Enable-Migrations时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了运行Enable-Migrations时出错相关的知识,希望对你有一定的参考价值。
我在ASP.NET MVC5项目(Powershell v5和Visual Studio 2015)上运行Enable-Migrations时出现以下错误。我试图卸载并重新安装EntityFramework(v6.1.3),但没有幸运。有谁知道如何解决它?
类型名称'Microsoft.VisualStudio.Shell.Package'不明确,可能是'Microsoft.VisualStudio.Shell.Package,Microsoft.VisualStudio.Shell.14.0,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或' Microsoft.VisualStudio.Shell.Package,Microsoft.VisualStudio.Shell.11.0,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。在C: PROGRAM FILES(X86) MICROSOFT VISUAL STUDIO 14.0 COMMON7 IDE EXTENSIONS MSHGPU2S.W4I Modules NuGet profile.ps1:126 char:5 + $ service = [Microsoft.VisualStudio.Shell.Package] :: GetGlobalServi ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(:) [],RuntimeException + FullyQualifiedErrorId:AmbiguousTypeReference
类型名称'NuGet.VisualStudio.IVsPackageInstallerServices'不明确,可能是'NuGet.VisualStudio.IVsPackageInstallerServices,Microsoft.VisualStudio.ApplicationInsights,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或'NuGet.VisualStudio.IVsPackageInstallerServices, Microsoft.VisualStudio.Web.Application,Version = 14.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:1004 char:5 + $ packageInstallerServices = $ componentModel.GetService([NuGet.Vis ... + ~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ + CategoryInfo:InvalidArgument:(:) [],RuntimeException + FullyQualifiedErrorId:AmbiguousTypeReference
您无法在空值表达式上调用方法。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:1006 char:5 + $ vsPackage = $ packageInstallerServices.GetInstalledPackages()| ? ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation :( :) [],RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull
Join-Path:无法将参数绑定到参数'Path',因为它为null。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:713 char:28 + $ toolsPath = Join-Path $ installPath tools + ~~~~~~~~~~~~ + CategoryInfo: InvalidData:(:) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Join-Path:无法将参数绑定到参数'Path',因为它为null。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:780 char:74 + ... [System.Reflection.Assembly] :: LoadFrom((Join-Path $ ToolsPath EntityF ... + ~~~~~~~~~~ + CategoryInfo:InvalidData :( :) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
您无法在空值表达式上调用方法。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:781 char:5 + $ dispatcher = $ utilityAssembly.CreateInstance(+ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation :( :) [],RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull
Join-Path:无法将参数绑定到参数'Path',因为它为null。在D: xxx packages EntityFramework.6.1.3 tools EntityFramework.psm1:810 char:20 +(Join-Path $ runner.ToolsPath EntityFramework.PowerShell.dll),+ ~~~~~~~~~ ~~~~~~~~ + CategoryInfo:InvalidData :( :) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
如果您有11099到14257之间的任何Windows 10 Insider预览版本,则这是一个已知错误
官方错误报告https://entityframework.codeplex.com/workitem/2872
以上是关于运行Enable-Migrations时出错的主要内容,如果未能解决你的问题,请参考以下文章
包管理器控制台 Enable-Migrations CommandNotFoundException 仅在特定的 VS 项目中
Web API系列教程3.3 — 实战:处理数据(建立数据库)