.net - Entity Framework 代码优先迁移错误

标签 .net entity-framework exception-handling ef-code-first

我是 MVC 4 和 Entity Framework 的新手,当我从包管理器控制台运行此命令时:

Enable-Migrations -ContextTypeName MyFirstMvcApp.Models.InventoryDbContext

加入路径:无法将参数绑定(bind)到参数“路径”,因为它为空。

我收到以下错误:
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:363 char:27
+     $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:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:392 char:73
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<<  $toolsPath EntityFramework.PowerShell.Utility.dll))
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand

You cannot call a method on a null-valued expression.
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:393 char:50
+     $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo          : InvalidOperation: (CreateInstance:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:426 char:19
+         (Join-Path <<<<  $runner.ToolsPath EntityFramework.PowerShell.dll),
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand

我该如何解决?
请注意,我使用的是带有 SP1 的 Visual Studio 2010 Ultimate,并且我在此 link 中安装了 MVC4。 .

最佳答案

通过卸载并重新安装 Entity Framework 来修复它。
为了他人的利益,这里是命令...

卸载:

PM> Uninstall-Package EntityFramework -Force



卸载后重新安装EntityFramework:

PM> Install-Package EntityFramework -Pre



那里!它是固定的。虽然我仍然不知道是什么导致了问题。

关于.net - Entity Framework 代码优先迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14410987/

相关文章:

entity-framework - Entity Framework 看不到 View 的计算列

c# - Exception.Message 与 Exception.ToString()

c# - 什么时候适合使用错误代码?

.net - Twitter API - 获取 GPS 点附近的推文

c# - SQL Server 2008 中的正则表达式

c# - 无窗口wpf应用程序示例?

c# - 防止在 Entity Framework 中的相关表实体上添加新记录

使用 FindByIdAsync 时取消 ASP.Net Core Identity

java - PMD 错误 - AvoidThrowingRawExceptionTypes

C#不继承基类的构造函数