EF6 迁移在 VS 2015 RC 上停止工作

EF6 migrations stopped working on VS 2015 RC

我一直在使用 VS2015CTP,现在我决定将它升级到 VS2015 Community RC 由于某些未知原因,我的项目迁移停止工作。

在 Visual Studio 2015 年,我收到以下消息>

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> 

如果我在 VS 2013 中打开解决方案并且 运行 上面的命令一切正常。 这是 VS 中的一些错误,它是否丢失了对某些内容的引用? 有没有办法激活某种更广泛的日志,我真的不喜欢调试 EF。

谢谢

编辑: 我认为这与 Nuget 在 Visual Studio 2015 中的处理方式有关,似乎它并没有以相同的方式看待 nuget.config。 我将跨多个解决方案的所有包都放在同一个文件夹中,为此,我在 .nuget 文件夹下使用 nuget.config,其中:

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

出于某种原因,似乎 VS2015 处理此问题的方式与 VS2013 不同,因为它尝试将包下载到解决方案文件夹下的文件夹 packages。

已将 Entity Framework 版本从 6.1.3 降级到 EF 6.1.2,现在可以使用了。

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

另一个原因可能是在两个或多个项目中使用 EF (https://github.com/NuGet/Home/issues/528)

临时解决方案:评论

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

在其所有 "packages.config" 中仅留下未注释的项目,您希望使用迁移。

问题源于多个项目引用 EF。

None 的现有答案对我有用。我可以解决的唯一方法是卸载所有引用 EF 的项目,而不是我 运行 Update-Database 所在的项目。

这是由 NuGet 错误引起的

Enable Migrations Error

建议的解决方法是

安装可解决此问题的更新的 NuGet 客户端 https://nuget.codeplex.com/releases/view/615507

下载 EntityFramework.psm1

的补丁版本

EntityFramwework.psm1

复制到packages\EntityFramework.6.1.3\tools目录,重启Visual Studio,再试。

卸载引用 Entity Framework

的其他项目

因此唯一加载的引用 Entity Framework 的项目是包含您的 EF 模型的项目