Rui Lima
Rui Lima

Reputation: 7403

EF6 migrations stopped working on VS 2015 RC

I've been using VS2015CTP now I decided to upgrade it to VS2015 Community RC For some unknown reason migrations on my projects stopped working.

In Visual Studio 2015 I get the following message>

PM> update-database
Exception calling "LoadFrom" with "1" argument(s): "The specified path, file name, or both are too long. The fully qualified file name must be less 
than 260 characters, and the directory name must be less than 248 characters."
At G:\Projects\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:5
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PathTooLongException

You cannot call a method on a null-valued expression.
At G:\Projects\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): "The specified path, file name, or both are too long. The fully qualified file name 
must be less than 260 characters, and the directory name must be less than 248 characters."
At G:\Projects\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:5
+     $domain.CreateInstanceFrom(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PathTooLongException

PM> 

If I open the solution in VS 2013 and run the above command everything works fine. Is this some bug in VS, did it lose reference to something? Is there a way to activate some sort of more extensive log, I really don't feel into debug EF.

Thanks

Edit: I think this has something to do with the way Nuget is handled in Visual Studio 2015, it seems it doesn't look at nuget.config the same way. I have all the packages across several solutions in the same folder, to do this I use a nuget.config under .nuget folder with:

<config>
    <add key="repositoryPath" value="G:/Projects/packages" />
</config>

for some reason it seems that VS2015 is not handling this the same way as VS2013 because it tries to download the packages to the folder packages under the solution folder.

Upvotes: 6

Views: 2651

Answers (4)

Clint Good
Clint Good

Reputation: 850

This is caused by a NuGet bug

See Enable Migrations Error

The suggested workarounds are

Install an updated NuGet client that resolves this issue https://nuget.codeplex.com/releases/view/615507

Download this patched version of EntityFramework.psm1

EntityFramwework.psm1

Copy it into the packages\EntityFramework.6.1.3\tools directory, restart Visual Studio, and try again.

Unload other projects that reference Entity Framework

So that the only loaded project that references Entity Framework is the one that contains your EF model

Upvotes: 0

RagtimeWilly
RagtimeWilly

Reputation: 5445

Issue stems from having multiple projects referencing EF.

None of the existing answers worked for me. The only way I could resolve was to unload all projects referencing EF other than the one I was running Update-Database on.

Upvotes: 1

RouR
RouR

Reputation: 6336

Another reason can be in using EF in two or more projects (https://github.com/NuGet/Home/issues/528)

Temporary solution: Comment

<package id="EntityFramework" version="6.1.3" targetFramework="net46" userInstalled="true" /> 

of all its "packages.config" leaving uncommented only the project you want to work with Migrations.

Upvotes: 1

Rui Lima
Rui Lima

Reputation: 7403

Downgraded the Entity Framework version from 6.1.3 to EF 6.1.2 and now it works.

https://github.com/aspnet/EntityFramework/issues/1950

Upvotes: 5

Related Questions