同一个图书馆之间的模糊呼叫?

时间:2015-10-31 02:55:03

标签: c# macos asp.net-core dnx

我正在尝试将我的ASP.NET 5项目从beta7升级到beta8。我得到了运行时并切换了project.json中的各种包。几乎所有东西都在编译,除了我得到一些我无法解决的错误。

特别是,这是让我感到困惑并阻止我前进的那个:

DNX,Version=v4.5.1 error CS0121: The call is ambiguous between the following methods or properties: 
'Microsoft.Data.Entity.SqlServerDbContextOptionsExtensions.UseSqlServer(Microsoft.Data.Entity.DbContextOptionsBuilder, string)' and 
'Microsoft.Data.Entity.SqlServerDbContextOptionsExtensions.UseSqlServer(Microsoft.Data.Entity.DbContextOptionsBuilder, string)'

Startup.cs

的这一行代码中
services.AddEntityFramework()
        .AddSqlServer()
        .AddDbContext<MyContext>(options =>
                     options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

我知道在过去,这通常会出现在我的GAC中另一个版本的库中。但是,我不认为这是OSX的情况。我检查了我的〜/ .dnx / packages /文件夹,看看是否有任何东西跳出来,但也没有。

这是我的project.json供参考(修剪了一些部分):

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

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-beta8",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-beta8",
    "HtmlSanitizer": "2.0.5623.30465",
    "ImageProcessor": "2.3.0.0",
    "Microsoft.AspNet.Antiforgery": "1.0.0-beta8",
    "Microsoft.AspNet.Authorization": "1.0.0-beta8",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta8",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
    "Microsoft.AspNet.Mvc": "6.0.0-beta8",
    "Microsoft.AspNet.Mvc.DataAnnotations": "6.0.0-beta8",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta8",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta8",
    "Microsoft.Dnx.Runtime": "1.0.0-beta8",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-beta8",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0-beta8",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-beta8",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-beta8",
    "Microsoft.Extensions.Logging.Console": "1.0.0-beta8",
    "System.Net.Http": "4.0.1-beta-23225"
  },

  "commands": {
    "ef": "EntityFramework.Commands",
    "kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000 --ASPNET_ENV Development"
  },

    "frameworks": {
        "dnx451": {
            "frameworkAssemblies": {
                "System.Drawing": "4.0.0.0",
                "System.Runtime.Serialization": "4.0.0.0"
            }
         }
    },
    TRIMMED HERE
}

更新 我在dnu build中看到一组可能表示可能出现问题的警告。

/Users/jasoncavett/Projects/web-cemeteries/obituaries/project.json(7,43): warning NU1007: Dependency specified was EntityFramework.MicrosoftSqlServer >= 7.0.0-beta8 but ended up with EntityFramework.MicrosoftSqlServer 7.0.0-rc1-15945. /Users/jasoncavett/Projects/web-cemeteries/obituaries/project.json(21,48): warning NU1007: Dependency specified was Microsoft.Extensions.CodeGenerators.Mvc >= 1.0.0-beta8 but ended up with Microsoft.Extensions.CodeGenerators.Mvc 1.0.0-rc1-15824. /Users/jasoncavett/Projects/web-cemeteries/obituaries/project.json(25,45): warning NU1007: Dependency specified was Microsoft.Extensions.Logging.Console >= 1.0.0-beta8 but ended up with Microsoft.Extensions.Logging.Console 1.0.0-rc1-15673.

1 个答案:

答案 0 :(得分:1)

检查您的nuget Feed是否来自发行版,而不是来自开发分支(很可能是您的问题) 您可能不需要此Feed

https://www.myget.org/F/aspnetrelease/api/v3/index.json

但我认为你错过了这个饲料

"sdk": {
  "version": "1.0.0-beta8"
 }

检查你的global.json是否为beta8

Active Version         Runtime Architecture OperatingSystem Alias
------ -------         ------- ------------ --------------- -----
   1.0.0-beta4     clr     x86          win
   1.0.0-beta7     clr     x64          win
   1.0.0-beta7     clr     x86          win             b7
   1.0.0-beta7     coreclr x64          win
   1.0.0-beta7     coreclr x86          win
   1.0.0-beta8     clr     x64          win
*  1.0.0-beta8     clr     x86          win             aa, b8
   1.0.0-beta8     coreclr x64          win
   1.0.0-beta8     coreclr x86          win
   1.0.0-rc1-15838 clr     x86          win             rc1a

如果您在使用dnu恢复之前将活动dnx设置为运行beta8,请检查您的dnvm。

C:\ git \ DBC&gt; dnvm list

./conf

如果您仍有问题,请检查您的无效参考project.json。