启用迁移不适用于具有现有数据库配置的项目

Enable-Migrations not working in project with existing db configurations

我正在尝试 运行 Enable-Migrations cmd-let 在具有现有数据库配置的解决方案中,但无论我尝试哪种选项组合,我都会收到以下错误:

Exception calling "LoadFrom" with "1" argument(s): "Invalid directory on URL."
At my-project\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:5
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

You cannot call a method on a null-valued expression.
At my-project\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:5
+     $dispatcher = $utilityAssembly.CreateInstance(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Exception calling "CreateInstanceFrom" with "8" argument(s): "Invalid directory on URL."
At my-project\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:5
+     $domain.CreateInstanceFrom(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

解决方案的结构如下:

Foo.sln
┖─ DbCreator (command line program, transfers data from an old db)
┖─ Foo.Api (WebAPI project, default startup project)
┖─ Foo.Repository (Contains entities and DbContext)
┖─ other utility and test projects

我想做的是查看 Foo.Repository 中的 DbContext(解决方案中唯一的一个),并允许迁移到 DbCreator 项目,所以每次我 运行 exe 时我都可以 运行 迁移。

我正在使用 VS 2015 和 EF 6.1.3。

这是一个已知问题,解决方法请查看 1950#issue