Tomas Aschan
Tomas Aschan

Reputation: 60624

Enable-Migrations not working in project with existing db configurations

I'm trying to run the Enable-Migrations cmd-let in a solution with an already existing db configuration, but no matter what combination of options I try, I get the following error:

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

The solution is structured like this:

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

What I'd like to do, is to look at the DbContext in Foo.Repository (the only one in the solution), and enable migrations into the DbCreator project, so I can run the migrations every time I run the exe.

I'm using VS 2015 and EF 6.1.3.

Upvotes: 3

Views: 573

Answers (1)

Asif Mushtaq
Asif Mushtaq

Reputation: 13150

Its a know issue, for workaround have a look at 1950#issue

Upvotes: 2

Related Questions