【发布时间】:2015-08-25 20:28:58
【问题描述】:
目前我试图将我的数据模型分离到同一个解决方案中的不同项目中,首先使用代码。如果我只有一个安装了 EF(6.1.3) 的项目,迁移 (Enable-Migration, Add-Migration) 将按预期工作。
但是当我添加另一个项目并安装 EF 数据包时,如果我尝试Enable-Migration,我会收到此错误:
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:713 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 C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 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 C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 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 C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 char:19
+ (Join-Path <<<< $runner.ToolsPath EntityFramework.PowerShell.dll),
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
EF 似乎在这两个项目中都运行良好。将 EF 重新安装到其中一个或两个项目并没有解决它。有什么解决方案吗?
编辑:我用 3 个项目开始了一个新的解决方案,1. 用于基本上下文(public class BaseContext<TContext> : DbContext where TContext : DbContext ...),2. 用于基类,3. 用于基于基本上下文和类创建上下文。如果我只将 ef 放入一个中,那么迁移工作,或者至少告诉我它找不到上下文,但如果我将它安装到多个中,那么它会再次产生错误。
【问题讨论】:
标签: entity-framework powershell model-view-controller database-migration