Visual Studio 2015 RC Entity Framework 6.1.3 迁移错误

Visual Studio 2015 RC Entity Framework 6.1.3 Migrations Error

仅当解决方案有多个引用 EntityFramework 的项目时,才会出现下面粘贴的错误。 当 运行 "Enable-Migrations" 或 "Add-Migration" 时,我收到以下错误:

New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again. At D:\Projetos\Monitoramento\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:757 char:13 + $info = New-Object System.AppDomainSetup -Property @{ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [New-Object], Exception + FullyQualifiedErrorId : SetValueException,Microsoft.PowerShell.Commands.NewObjectCommand The property 'PrivateBinPath' cannot be found on this object. Verify that the property exists and can be set. At D:\Projetos\Monitoramento\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:772 char:9 + $info.PrivateBinPath += ';lib\net45' + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound 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 D:\Projetos\Monitoramento\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 D:\Projetos\Monitoramento\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 D:\Projetos\Monitoramento\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 char:5 + $domain.CreateInstanceFrom( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : PathTooLongException

输出 EntityFramework 6.1.1:

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 C:\Users\Hudson\Documents\Visual Studio 2015\Projects\WpfApplication4\packages\EntityFramework.6.1.1\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 C:\Users\Hudson\Documents\Visual Studio 2015\Projects\WpfApplication4\packages\EntityFramework.6.1.1\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 C:\Users\Hudson\Documents\Visual Studio 2015\Projects\WpfApplication4\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:809 char:5 + $domain.CreateInstanceFrom( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : PathTooLongException

我有同样的问题:(

我的解决方法是:

  1. 将 Entity Framework 降级到 v6.1.1(至少新的 NuGet GUI 使这非常容易)
  2. 运行 包管理器控制台上的命令(例如 Add-Migration ...)。似乎在这个版本中有效
  3. 升级回 Entity Framework v6.1.3

似乎是一个普遍的问题,但显然很难回购?

Enable-migrations error #1950

建议您在上面添加您的问题详情,希望能尽快解决。

我找到了一个临时解决方案: 评论 <package id="EntityFramework" version="6.1.3" targetFramework="net46" userInstalled="true" /> 的所有 "packages.config",只留下未评论的项目,您希望使用迁移。

团队 EntityFramework (https://github.com/aspnet/EntityFramework/issues/1950) and NuGet (https://github.com/NuGet/Home/issues/528) 已经意识到这个问题,我们很快就会有最终的解决方案。

其他解决方案:https://github.com/aspnet/EntityFramework/issues/1950#issuecomment-99164398

复制this patched version of EntityFramework.psm1.

按照comment by yishaigalatzer on EF bug #1950, NuGet 3.0 RC2 has now been released, which should fix this problem. Simply download the VSIX from codeplex并安装它。

这解决了我的问题。

就我而言,我只是:

1.封闭VS。
2. 手动删除 packages 文件夹中的 Entity Framework 包。
3. 打开项目并恢复包。

这对我有用。