[英]'Microsoft.NETCore.App 2.0.0 not found in Package Manager Console
I recently upgraded my .NET projects from .NET 5.0 to .NET 6.0.我最近将我的 .NET 项目从 .NET 5.0 升级到 .NET 6.0。
When I attempt to add a migration in Package Manager Console, I get the following error.当我尝试在 Package 管理器控制台中添加迁移时,出现以下错误。
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
- The following frameworks were found:
5.0.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
6.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64
I'm confused by this.我对此感到困惑。 Why is it looking for version 2.0.0 of Microsoft.NETCore.App ?
为什么要寻找Microsoft.NETCore.App的 2.0.0 版? Is that an older version?
那是旧版本吗? And why would it be missing now that I've updated my projects to .NET 6.0?
为什么现在我已经将我的项目更新为 .NET 6.0,它会丢失?
I looked in my project but don't see any reference to this package. Can anyone help me understand what is wrong?我查看了我的项目,但没有看到任何对此 package 的引用。任何人都可以帮助我了解哪里出了问题吗?
Update更新
Here is the project file for my main application.这是我的主要应用程序的项目文件。
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TTRailtraxBusinessLayer\TTRailtraxBusinessLayer.csproj" />
<ProjectReference Include="..\TTRailtraxEntities\TTRailtraxEntities.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Attributes\" />
</ItemGroup>
</Project>
And here is the project file for the library project that contains my entities.这是包含我的实体的库项目的项目文件。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RailtraxCore\RailtraxCore.csproj" />
</ItemGroup>
</Project>
As you can see, there are other library projects being used as well.如您所见,还使用了其他库项目。
Well, Entity Framework's tooling for Powershell has a semantic to pass parameters into EF tools.好吧,Entity Framework 的 Powershell 工具具有将参数传递到 EF 工具的语义。 It passes both the default project and the startup project but for multiple startup projects, it uses the default project as a fallback project.
它同时传递默认项目和启动项目,但对于多个启动项目,它使用默认项目作为后备项目。 EF tools requires a configured DbContext (associated with a provider and connection string) this is the startup project that consumes the DbContext and configures it.
EF 工具需要一个已配置的 DbContext(与提供程序和连接字符串相关联),这是使用 DbContext 并对其进行配置的启动项目。 And a migration assembly that locates the migrations and that is usually the project that contains DbContext.
以及一个定位迁移的迁移程序集,通常是包含 DbContext 的项目。 So generally when I add migrations with PMC I set the startup project to an application and set the default project in PMC to the DbContext project.
因此,通常当我使用 PMC 添加迁移时,我将启动项目设置为应用程序,并将 PMC 中的默认项目设置为 DbContext 项目。
Here is the Powershell module if you want to dig deeper.如果您想深入挖掘, 这里是 Powershell 模块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.