c# - NU1107 : . Microsoft.EntityFrameworkCore.SqlServer 的 Net Core 2.1 兼容替代品?

标签 c# visual-studio asp.net-core-3.0

我正在关注 creating an MVC application with .Net Core 3.1 的 Microsoft 教程.我在 Visual Studio 2017 中使用 .Net Core 2.1。我的 Visual Studio 实例由我的公司管理,因此我无法升级到 .Net Core 3.1,因为它需要 Visual Studio 2019。

关于 install the NuGet package for SqlServer 的步骤,我收到错误 NU1107,因为包的 .NetCore 版本与我的项目版本不匹配。

有没有办法在不安装 .Net Core 3.1 的情况下解决这个错误?也许要使用不同的包?

Install-Package : NU1107: Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 3.1.0 directly to project MvcMovie to resolve this issue. 
 MvcMovie -> Microsoft.EntityFrameworkCore.SqlServer 3.1.0 -> Microsoft.EntityFrameworkCore.Relational 3.1.0 -> Microsoft.EntityFrameworkCore (>= 3.1.0) 
 MvcMovie -> Microsoft.AspNetCore.App 2.1.1 -> Microsoft.EntityFrameworkCore (>= 2.1.1 && < 2.2.0).
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Install-Package : Package restore failed. Rolling back package changes for 'MvcMovie'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.SqlServer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

更新

我在尝试使用 .Net Core 2.1 环境学习 .Net Core 3 教程时遇到了更多问题,最终发现我可以使用旧版本的教程!我责怪横幅盲。

Use an older version of the tutorial with the "Version" dropdown on the upper left menu

最佳答案

右键单击您的项目并打开“管理 Nuget 包...”。 (下面突出显示)

menu with option

搜索 Nuget 包 Microsoft.EntityFrameworkCore.SqlServer,并将版本更改为较旧的 2.2 版本。然后安装该版本的 Nuget 包。 (也突出显示)

Highlighted steps

这应该可以解决您与 Microsoft.AspNetCore.App 的冲突。

关于c# - NU1107 : . Microsoft.EntityFrameworkCore.SqlServer 的 Net Core 2.1 兼容替代品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59275712/

相关文章:

c# - XAML 中的 Xamarin.Forms ListView 自动高度

c# - 处理 "application not found"等特定 Win32 异常的最佳方法是什么?

c - 为什么 -o 是要从 Microsoft 编译器和链接器中删除的候选对象?

visual-studio-2019 - 当我执行 "dotnet run"时出现构建错误

c# - 自定义 AuthenticationHandler 在 Asp.Net Core 3 中不起作用

c# - 多线程读取大型txt文件?

c# - Linq 查询在本地机器上运行良好,但在服务器上出现 "The connection was reset"错误

c#:发送文件,混合成功文件和损坏文件

visual-studio - Visual Studio 2010 : adding a service reference to a 2008 generated wsdl

c# - ASP.NET Core 3.0 中的 JsonOutputFormatter