繁体   English   中英

无法使用Entity Framework和Visual Studio 2015添加迁移

[英]Unable to add migration using Entity Framework and Visual Studio 2015

我刚刚安装了Visual Studio 2015 Express版,是从Visual Studio 2013 Express升级的。 现在,我无法使用代码优先迁移来更新一个项目中一直使用的数据库。 我所做的只是从名为“ Prospect”的类中的名为“ field”的属性中删除了[Required]数据注释。

我曾尝试将Entity Framework升级到6.2.3并完全重新安装,但都没有成功,我目前正在使用6.1.2版。

在Visual Studio 2013中,“添加-迁移”命令工作正常,但是当尝试在Visual Studio 2015中添加迁移时,程序包管理控制台中会产生以下错误;

PM>添加迁移remove_required_field_from_prospect无法找到

键入[NuGet.VisualStudio.IVsPackageInstallerServices]。 确保包含此类型的程序集已加载。 在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您不能在空值表达式上调用方法。在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连接路径:由于参数'Path'为空,因此无法将其绑定到D:\\ Repos \\ PDintel \\ PDintel \\ packages \\ EntityFramework.6.1.2 \\ tools \\ EntityFramework.psm1 :713字符:28 + $ toolsPath = Join-Path $ installPath工具+ ~~~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [Join-Path],ParameterBindingValidationException + FullyQualifiedErrorId:ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand加入-Path:无法将参数绑定到参数“ Path”,因为它为null。 在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您不能在空值表达式上调用方法。 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:无法将参数绑定到参数'Path',因为它为空。在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

如果您需要更多信息,请询问!

任何帮助将不胜感激!

更新每当我尝试使用实体框架执行任何操作时,似乎都会出现此错误,即使“启用迁移”也会触发该错误。

原来这是程序包管理控制台的一个错误,现已修复!

如果您的解决方案中有一个.nuget文件夹,请检查那里的nuget.exe版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM