实体框架代码首次迁移错误 [英] Entity Framework Code First Migration Error

查看:123
本文介绍了实体框架代码首次迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new to MVC 4 and entity framework and when I run this command from the package manager console:

Enable-Migrations -ContextTypeName MyFirstMvcApp.Models.InventoryDbContext

Join-Path:无法将参数绑定到参数'Path'因为它是空的。

Join-Path : Cannot bind argument to parameter 'Path' because it is null.

我收到以下错误:

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

如何解决这个问题?
请注意,我正在使用Visual Studio 2010 Ultimate SP1和我已经在此链接中安装了MVC4 。

How do I fix this? Note that I am using Visual Studio 2010 Ultimate with SP1 and I have installed MVC4 in this link.

推荐答案

通过卸载和重新安装实体框架来修复它。
为了别人的利益,这里是命令...

Fixed it by uninstalling and re-installing entity framework. For the benefit of others, here are the commands...

卸载:


PM>卸载程序包EntityFramework -Force

PM> Uninstall-Package EntityFramework -Force

卸载后,重新安装EntityFramework:

After uninstalling, reinstall EntityFramework:


PM> Install-Package EntityFramework -Pre

PM> Install-Package EntityFramework -Pre

有!它是固定的虽然我还不知道是什么原因造成的。

There! It's fixed. Though I still don't know what caused the problem.

这篇关于实体框架代码首次迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆