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

时间:2015-07-08 08:10:42

标签: entity-framework-6 ef-migrations

我尝试在已有db配置的解决方案中运行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

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

我正在使用VS 2015和EF 6.1.3。

1 个答案:

答案 0 :(得分:2)

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

相关问题