【问题标题】:EF6 migrations stopped working on VS 2015 RCEF6 迁移停止在 VS 2015 RC 上运行
【发布时间】:2015-05-03 22:44:54
【问题描述】:

我一直在使用 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。

谢谢

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

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

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

【问题讨论】:

    标签: entity-framework-6 visual-studio-2015


    【解决方案1】:

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

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

    【讨论】:

    • 所以微软刚刚从 6.1.3 中删除了功能。他们真好。如果他们可以删除 Windows 8 和 10,那么我们都会很高兴 :-)
    【解决方案2】:

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

    临时解决方案:评论

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

    在它的所有“packages.config”中,只留下您想要使用迁移的项目。

    【讨论】:

      【解决方案3】:

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

      现有的答案都不适合我。我能解决的唯一方法是卸载所有引用 EF 的项目,而不是我正在运行 Update-Database 的项目。

      【讨论】:

        【解决方案4】:

        这是由 NuGet 错误引起的

        Enable Migrations Error

        建议的解决方法是

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

        下载 EntityFramework.psm1 的修补版本

        EntityFramwework.psm1

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

        卸载引用实体框架的其他项目

        因此,唯一加载的引用实体框架的项目是包含您的 EF 模型的项目

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-05-14
          • 2017-08-08
          • 1970-01-01
          • 2017-10-03
          • 2015-07-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多