【问题标题】:'EntityFramework.Core, Version=7.0.0.0, uses 'System.Linq.Expressions, Version=4.0.11.0'EntityFramework.Core,版本=7.0.0.0,使用'System.Linq.Expressions,版本=4.0.11.0
【发布时间】:2016-02-23 11:14:45
【问题描述】:

我有一个包含三个项目的 ASP.NET 5.0 解决方案

  1. MVC 项目
  2. 数据访问项目
  3. 实体定义

在尝试将项目从 ASP.NET 5 和 EF 7 的 beta-8 升级到 RC1-final 后,我收到以下错误(在我查看的任何搜索中都没有产生任何结果)。

****错误: 错误 CS1705 程序集 'EntityFramework.Core' 标识为 'EntityFramework.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' 使用 'System.Linq.Expressions, Version=4.0.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ' 它的版本比引用的程序集 'System.Linq.Expressions' 的版本更高,标识为 'System.Linq.Expressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ASS.DomainDataModel****

我尝试通过包管理器控制台加载不同版本的 System.Linq,针对所有三个项目,并从所有项目的 project.json 文件中删除 System.Linq 并将其重新添加,在那里也尝试不同的版本。我尝试解决这个问题的时间越长,我就越感到困惑。我想我错过了一些非常明显的东西......

按照建议,这里是三个project.json文件的内容

MVC 项目:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "System.Linq.Parallel": "4.0.1-beta-23516", 
    "ASS.DomainClasses": "1.0.0-*",
    "ASS.DomainDataModel": "1.0.0-*"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "System.Linq.Expressions": "4.0.11-beta-23516"
      }
    },
    "dnxcore50": {
      "dependencies": {
        "System.Linq.Expressions": "4.0.10"
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

数据访问项目:

{
  "version": "1.0.0-*",
  "description": "ASS.DomainDataModel Class Library",
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "System.Linq.Expressions": "4.0.11-beta-23516"
      }
    },
    "dnxcore50": {
      "dependencies": {
      }
    }
  },

  "dependencies": {
    "ASS.DomainClasses": "1.0.0-*",
    "Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.Relational": "7.0.0-rc1-final"
  },

    "commands": {
    "ef": "EntityFramework.Commands"
  }
}

实体定义项目:

{
  "version": "1.0.0-*",
  "description": "ASS.DomainClasses Class Library",
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "System.Linq.Expressions": "4.0.11-beta-23516"
      }
    },
    "dnxcore50": {
      "dependencies": {
        "Microsoft.CSharp": "4.0.1-beta-23516",
        "System.Collections": "4.0.11-beta-23516",
        "System.Linq.Expressions": "4.0.10",
        "System.Runtime": "4.0.21-beta-23516",
        "System.Threading": "4.0.11-beta-23516"
      }
    }
  }
}

【问题讨论】:

  • 通常出现这样的错误,您必须进入您的 web.config 文件并更改所有使用 System.Linq.Expressions 来指代较新版本号的位置。
  • 我认为您应该将所有 3 个项目的 project.json 文件添加到您的问题中以获得此类问题的帮助
  • 谢谢大家。添加 json 文件甚至帮助我获得了更好的概览。 @StriplingWarrior,ASP.NET 5 不再使用 web.config 来处理这些事情。相反,它使用 json 文件来配置应用程序。

标签: c# linq asp.net-core entity-framework-core


【解决方案1】:

project.json 中的"dependencies""frameworkAssemblies" 之间存在细微差别。您的 "dnx451" 框架正在使用 System.Linq.Expressions 的打包版本。您更有可能需要指定框架程序集。 (猜测是因为我不知道您项目的确切要求。)

What is the difference between 'dependencies' and 'frameworkAssemblies' in project.json?

另外,这可能是由于 ASS.DomainDataModel 不兼容造成的。

【讨论】:

  • 谢谢!这确实澄清了事情。在这里查看所有三个项目文件可以更容易地发现结构问题。所以我现在已经从框架依赖项中删除了各个条目,并在所有三个项目文件的“根”级依赖项部分创建了一个条目,现在 sln 构建没有问题。
猜你喜欢
  • 2016-08-15
  • 2015-12-23
  • 2019-07-23
  • 1970-01-01
  • 2021-09-29
  • 2021-10-27
  • 2016-07-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多