我最近將我的 .NET 專案從 .NET 5.0 升級到 .NET 6.0。
當我嘗試在包管理器控制臺中添加遷移時,出現以下錯誤。
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
我對此感到困惑。為什么要尋找Microsoft.NETCore.App 的2.0.0 版?那是舊版本嗎?為什么我已經將我的專案更新到 .NET 6.0 之后它會丟失?
我查看了我的專案,但沒有看到對這個包的任何參考。誰能幫我理解什么是錯的?
更新
這是我的主要應用程式的專案檔案。
<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>
這是包含我的物體的庫專案的專案檔案。
<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>
如您所見,還使用了其他庫專案。
uj5u.com熱心網友回復:
好吧,物體框架的 Powershell 工具具有將引數傳遞到 EF 工具的語意。它同時傳遞默認專案和啟動專案,但對于多個啟動專案,它使用默認專案作為后備專案。EF 工具需要配置的 DbContext(與提供程式和連接字串相關聯),這是使用 DbContext 并對其進行配置的啟動專案。以及定位遷移的遷移程式集,通常是包含 DbContext 的專案。所以通常當我使用 PMC 添加遷移時,我將啟動專案設定為應用程式,并將 PMC 中的默認專案設定為 DbContext 專案。
如果你想深入挖掘,這里是 Powershell 模塊。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/371001.html
上一篇:c#比較字串陣列和型別陣列
