You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Microsoft.NETCore.App至2.1.0-rc及ASP.NET Core 2.1兼容问题求助

Fixing .NET Core 2.1 Upgrade & EF Views Compatibility Issue

Hey there! I get it, dealing with framework version mismatches when you're just starting out can be super frustrating. Let's break down exactly how to resolve this problem so you can get to using EF Views with ASP.NET Core 2.1.

The Root Cause

The error you're hitting happens because your project is still targeting .NET Core 2.0 (netcoreapp2.0), even after you upgraded the Microsoft.NETCore.App package. The Microsoft.AspNetCore.All 2.1.0-rc1-final package only supports projects targeting netcoreapp2.1, so NuGet blocks the installation until you update your project's target framework to match.

Step-by-Step Solution

  1. Install the .NET Core 2.1 SDK (RC1)
    First off, the reason you can't select ASP.NET Core 2.1 in Visual Studio's project creation wizard is likely because you don't have the matching SDK installed. Grab and install the .NET Core 2.1 RC1 SDK (make sure it's the same RC version as the packages you're trying to use).

  2. Update Your Project's Target Framework
    You need to switch your project to target .NET Core 2.1—this is the key fix:

    • Right-click your project in Solution Explorer → Select Properties
    • Navigate to the Application tab
    • Under Target framework, pick .NET Core 2.1 (this option will show up once you've installed the SDK)
    • Alternatively, edit your project's .csproj file directly:
      Replace this line:
      <TargetFramework>netcoreapp2.0</TargetFramework>
      
      With:
      <TargetFramework>netcoreapp2.1</TargetFramework>
      
  3. Clean Up and Reinstall NuGet Packages
    Now that your project targets the right framework, fix the package references:

    • Open the NuGet Package Manager, uninstall Microsoft.AspNetCore.All 2.0.8
    • Install Microsoft.AspNetCore.All 2.1.0-rc1-final (this should work without errors now)
    • Or use the Package Manager Console commands:
      Uninstall-Package Microsoft.AspNetCore.All
      Install-Package Microsoft.AspNetCore.All -Version 2.1.0-rc1-final
      
    • Quick note: For .NET Core 2.1+, Microsoft.NETCore.App is a framework reference, not a traditional NuGet package. You can remove the manual PackageReference for it in your .csproj—Visual Studio will handle it automatically once the target framework is set to 2.1.
  4. Verify and Test
    Rebuild your project to make sure there are no compilation errors. You should now be able to use Entity Framework's Views functionality with ASP.NET Core 2.1.

内容的提问来源于stack exchange,提问作者Ursus Schneider

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:39:43