【问题标题】:Update to EF 7.0.0-rc1-final broke SQL DbContextOptionsBuilder UseSqlServer更新到 EF 7.0.0-rc1-final 破坏了 SQL DbContextOptionsBuilder UseSqlServer
【发布时间】:2016-02-22 04:06:53
【问题描述】:

我刚刚将我的 nuget 包从之前的 EF 7 版本更新为 EF 7.0.0-rc1-final,它破坏了我的 sql 连接字符串代码。

using System.Collections.Generic;
using ComicEndpoints.Models;
using System.Threading.Tasks;
using Microsoft.Data.Entity;
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
    options.UseSqlServer(@"ConnectionString");
}

错误:

类型“DbContextOptionsBuilder”在一个程序集中定义,该程序集是 未参考。您必须添加对程序集的引用 'EntityFramework.Core,版本 7.0.0.0'

我已将 EntityFramework.Core 安装到 NuGet 中的最新版本,但我似乎无法通过“使用”来引用它。这只是在更新到 rc1-final 时发生的,我找不到任何引用更改的文档。

项目.JSON

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

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "EntityFramework.SqlServer": "7.0.0-beta8",
    "EntityFramework.SqlServer.Design": "7.0.0-beta8",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8",
    "Newtonsoft.Json": "8.0.1-beta2",
    "EntityFramework.Core": "7.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.WebApi.Cors": "5.2.3",
        "Microsoft.Owin.Cors": "3.0.1"
      }
    },
    "dnxcore50": { }
  },

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

【问题讨论】:

  • 您应该将 project.json 文件作为问题的一部分发布
  • 你还没有更新所有东西,有些东西你还有beta8
  • “Microsoft.Framework.Configuration.Json”需要重命名为Microsoft.Extensions.Configuration.Json才能得到rc1-final
  • 很糟糕的是,无论将来何时引入新的破坏性 API 更改,Visual Studio 工具都不会使更新所有依赖程序集的需要更加清晰。我认为整个 ASP.net 测试版是一个非常好的教育(对于作为消费者的我,对于作为生产者的开发这些工具的开发人员)如何对事物进行版本化。

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


【解决方案1】:

诀窍是删除 EntityFramework.SqlServer 并将其替换为 EntityFramework.MicrosoftSqlServer

查看这篇关于Upgrading ASP.NET 5 Beta 8 to RC1的博文

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.Relational": "7.0.0-rc1-final"
  },

【讨论】:

    【解决方案2】:

    我相信这个名字也变了:

    'EntityFramework.SqlServer': "7.0.0-rc1-final'

    ——现在是:

    'EntityFramework.MicrosoftSqlServer': "7.0.0-rc1-final'

    见帖子:Upgrading ASP.NET 5 Beta 8 to RC1

    提示:从 GitHub 下载 Asp.Net 文档,看看他们(ASP.NET 作者)如何对引用和依赖项进行编码...

    【讨论】:

    • 我同时拥有 beta 和 rc1 并且删除它有帮助
    【解决方案3】:

    您需要将所有内容更新到 rc1

    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "EntityFramework.SqlServer": "7.0.0-rc1-final",
    "EntityFramework.SqlServer.Design": "7.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Newtonsoft.Json": "8.0.1-beta2",
    "EntityFramework.Core": "7.0.0-rc1-final"
    

    我也怀疑您在 dnx451 下的依赖项以及这些依赖项是否合法或需要

    【讨论】:

    • 您的网络命令也需要更新为“web”:“Microsoft.AspNet.Server.Kestrel”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    • 2017-03-13
    • 2016-05-30
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 2018-10-23
    相关资源
    最近更新 更多