实体框架代码首次迁移错误
我是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.