简体   繁体   English

与程序包管理器控制台中的实体框架相关的项目启动出错

[英]Error on Project Startup relating to Entity Framework in Package Manager Console

This error has perplexed me for the last few days and can find little to no information on Google regarding this. 这个错误让我在过去的几天里感到困惑,并且几乎没有关于谷歌的信息。 This started the other day when I was assigned a new laptop by work and I'm essentially running this on a clean install of Windows 7 x64 with VS2012 Update 1. 有一天,当我被分配到新的笔记本电脑工作时,我基本上是在使用VS2012 Update 1的Windows 7 x64的干净安装上运行它。

Whenever I start up a project using Entity Framework 5 or 6-alpha, this exception gets thrown to the package manager console: 每当我使用Entity Framework 5或6-alpha启动项目时,此异常都会被抛出到包管理器控制台:

New-Object : Cannot find an overload for "Version" and the argument count: "2".
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:5 char:46
+ if ($PSVersionTable.PSVersion -ge (New-Object <<<<  Version @( 3, 0 )))
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

Test-ModuleManifest : Invalid Module Manifest path '<project path>
\packages\EntityFramework.5.0.0\tools\'. The path argument must resolve to a single file in the file system with a '
.psd1' extension. Please fix the path specification and try again.
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:14 char:34
+ $thisModule = Test-ModuleManifest <<<<  (Join-Path $toolsPath $thisModuleManifest)
    + CategoryInfo          : InvalidArgument: (C:\Users\stephe...rk.5.0.0\tools\:String) [Test-ModuleManifest], InvalidOper 
   ationException
    + FullyQualifiedErrorId : Modules_InvalidModuleManifestPath,Microsoft.PowerShell.Commands.TestModuleManifestCommand

Import-Module : Cannot bind argument to parameter 'Name' because it is null.
At <project path>\packages\EntityFramework.5.0.0\tools\in
it.ps1:31 char:18
+     Import-Module <<<<  $thisModule
    + CategoryInfo          : InvalidData: (:) [Import-Module], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ImportModuleComma 
   nd

I can get rid of this error by editing the package scripts manually, but that feels like it would be the wrong approach. 我可以通过手动编辑包脚本来摆脱这个错误,但感觉这是错误的方法。 There are also multiple instances of it checking the Powershell version in this manner so I'm suspecting it's something that's wrong with my computers's configuration. 还有多个实例以这种方式检查Powershell版本,所以我怀疑它是我的计算机配置错误的。

This is affecting multiple ASP.NET MVC 4 projects of mine targeting .NET 4.5. 这影响了我的.NET 4.5的多个ASP.NET MVC 4项目。 I can't run any Entity Framework commands such as Enable-Migrations or Update-Database as a result of this error. 由于此错误,我无法运行任何实体框架命令,例如Enable-Migrations或Update-Database。 Any clues will be greatly appreciated. 任何线索将不胜感激。

I finally got it to work, it was as simple as upgrading to PowerShell 3.0. 我终于开始工作,就像升级到PowerShell 3.0一样简单。 That kinda makes the version detection pointless, but hey, at least it works. 这有点让版本检测毫无意义,但嘿,至少它是有效的。

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

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