我刚刚安装了 .NET 6 SDK 并更新了我所有的项目以使用目标 net6.0
,但是当我尝试使用 dotnet
创建新的迁移时我得到的工具:
.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationIcon>assets-logo.ico</ApplicationIcon>
<RootNamespace>LC.Assets</RootNamespace>
<Authors>Stein Lundbeck</Authors>
<Company>Lundbeck Consulting</Company>
<Product>LC Assets</Product>
<Copyright>2021</Copyright>
</PropertyGroup>
<ItemGroup>
<Content Include="assets-logo.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LC.Components.Core\LC.Components.Core.csproj" />
<ProjectReference Include="..\LC.Components\LC.Components.csproj" />
</ItemGroup>
</Project>
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:
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.
我已经将 dotnet-ef
工具更新到 6.0.0 版本,所以我不知道仍然针对 2.0.0 版本的是什么。
Tool 'dotnet-ef' was successfully updated from version '5.0.4' to version '6.0.0'.
有什么想法吗?
最佳答案
我刚刚遇到了完全相同的问题。
我没有安装 Microsoft.NETCore.App 2.0.0,而是安装了 Entity Framework Core Design 包:
dotnet add package Microsoft.EntityFrameworkCore.Design
这让错误消失了。
注意:我记得遵循 EF 入门指南 ( https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli ) 让我安装了 Design 包,并且在遵循指南时没有抛出错误后,我想到了解决方案。
https://stackoverflow.com/questions/69998114/