无法使用 Entity Framework 和 Visual Studio 2015 添加迁移
Unable to add migration using Entity Framework and Visual Studio 2015
我刚刚安装了 Visual Studio 2015 Express 版,从 Visual Studio 2013 Express 升级而来。我现在无法使用代码优先迁移更新我在我的一个项目中使用的数据库。我所更改的只是从名为 "field" 的 属性 中删除名为 "Prospect" 的 class 中的 [Required]
数据注释。
我已经尝试将 Entity Framework 升级到 6.2.3 并完全重新安装,但都没有用,我目前使用的是 6.1.2 版本。
在 Visual Studio 2013 中,'Add-Migration' 命令工作正常,但是当尝试在 visual studio 2015 中添加迁移时,包管理控制台中会产生以下错误;
PM> Add-Migration remove_required_field_from_prospect Unable to find
type [NuGet.VisualStudio.IVsPackageInstallerServices]. Make sure that
the assembly that contains this type is loaded. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:1004
char:5
+ $packageInstallerServices = $componentModel.GetService([NuGet.VisualStudio.I ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (NuGet.VisualStu...stallerServices:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound You cannot call a method on a null-valued expression. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:1006
char:5
+ $vsPackage = $packageInstallerServices.GetInstalledPackages() | ?{ $_.Id -eq ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull Join-Path : Cannot bind argument to parameter 'Path' because it is null. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:713
char:28
+ $toolsPath = Join-Path $installPath tools
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Join-Path : Cannot bind argument to parameter 'Path' because it is
null. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:780
char:74
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
You cannot call a method on a null-valued expression. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:781
char:5
+ $dispatcher = $utilityAssembly.CreateInstance(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull Join-Path : Cannot bind argument to parameter 'Path' because it is null. At
D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:810
char:20
+ (Join-Path $runner.ToolsPath EntityFramework.PowerShell.dll),
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
如果您需要更多信息,请询问!
如有任何帮助,我们将不胜感激!
更新
每当我尝试使用 Entity Framework 执行任何操作时,似乎都会出现此错误,甚至 'Enable-Migrations' 也会触发它。
事实证明这是包管理控制台的错误,现已修复!
如果您的解决方案中有 .nuget 文件夹,请检查那里 nuget.exe 版本的版本...我的情况是更新该版本。
我刚刚安装了 Visual Studio 2015 Express 版,从 Visual Studio 2013 Express 升级而来。我现在无法使用代码优先迁移更新我在我的一个项目中使用的数据库。我所更改的只是从名为 "field" 的 属性 中删除名为 "Prospect" 的 class 中的 [Required]
数据注释。
我已经尝试将 Entity Framework 升级到 6.2.3 并完全重新安装,但都没有用,我目前使用的是 6.1.2 版本。
在 Visual Studio 2013 中,'Add-Migration' 命令工作正常,但是当尝试在 visual studio 2015 中添加迁移时,包管理控制台中会产生以下错误;
PM> Add-Migration remove_required_field_from_prospect Unable to find
type [NuGet.VisualStudio.IVsPackageInstallerServices]. Make sure that the assembly that contains this type is loaded. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:1004 char:5 + $packageInstallerServices = $componentModel.GetService([NuGet.VisualStudio.I ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (NuGet.VisualStu...stallerServices:TypeName) [], RuntimeException + FullyQualifiedErrorId : TypeNotFound You cannot call a method on a null-valued expression. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:1006 char:5 + $vsPackage = $packageInstallerServices.GetInstalledPackages() | ?{ $_.Id -eq ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Join-Path : Cannot bind argument to parameter 'Path' because it is null. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:713 char:28 + $toolsPath = Join-Path $installPath tools + ~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand Join-Path : Cannot bind argument to parameter 'Path' because it is null. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:780 char:74 + $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ... + ~~~~~~~ + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand You cannot call a method on a null-valued expression. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:781 char:5 + $dispatcher = $utilityAssembly.CreateInstance( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Join-Path : Cannot bind argument to parameter 'Path' because it is null. At D:\Repos\PDintel\PDintel\packages\EntityFramework.6.1.2\tools\EntityFramework.psm1:810 char:20 + (Join-Path $runner.ToolsPath EntityFramework.PowerShell.dll), + ~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
如果您需要更多信息,请询问!
如有任何帮助,我们将不胜感激!
更新 每当我尝试使用 Entity Framework 执行任何操作时,似乎都会出现此错误,甚至 'Enable-Migrations' 也会触发它。
事实证明这是包管理控制台的错误,现已修复!
如果您的解决方案中有 .nuget 文件夹,请检查那里 nuget.exe 版本的版本...我的情况是更新该版本。