asp.net-core - 安装 .NET 6 后无法创建 EF 迁移

我刚刚安装了 .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/

相关文章:

node.js - 使用 Fastify : "@nestjs/platform-express"

kotlin - 我正在尝试使用 Jetpack Compose 在 Android 中设置背景图片

r - 从列中提取日期并在 R 中缺少年份时添加年份

php - undefined variable : data , $data 未定义。拉维尔 8

bash - 组合两个 grep 命令来处理来自文件的输入,或者 grep 行以一个特定的子字符串开

docker - 无法启动守护进程 : pid file found, 确保 docker 未运行或

r - 如何对该数据集进行排序以创建合适的数据框

reactjs - 如何将参数传递给从自定义 Hook 转换的函数?

c# - 为什么不推荐使用堆来排序LinkedList?

c# - 添加到字节而不溢出