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

ASP.NET Core 6 Web API发布失败:Entity Framework迁移报错

ASP.NET Core 6 EF迁移失败(提示需安装dotnet-ef)解决方案
  • 检查全局工具路径是否纳入系统环境变量

    1. 执行命令确认dotnet-ef的安装状态及路径:
      dotnet tool list --global
      
    2. 将输出中dotnet-ef的安装路径添加到系统PATH环境变量,重启终端后重新执行迁移命令。
  • 尝试本地安装dotnet-ef到项目
    进入项目根目录,执行本地安装命令:

    dotnet tool install dotnet-ef --version 6.0.8 --local
    

    之后使用项目本地工具执行迁移操作:

    • Linux/macOS:./.dotnet/tools/dotnet-ef migrations add [你的迁移名称]
    • Windows:.dotnet\tools\dotnet-ef migrations add [你的迁移名称]
  • 确认项目EF相关包版本匹配
    检查项目中Microsoft.EntityFrameworkCore、Microsoft.EntityFrameworkCore.Design、Microsoft.EntityFrameworkCore.Tools等NuGet包的版本是否为6.0.8,若版本不一致,更新至6.0.8后重新尝试迁移。

  • 清理并重建项目
    依次执行以下命令,清理项目后重新构建:

    dotnet clean
    dotnet build
    

    构建完成后再次执行迁移命令。

内容的提问来源于stack exchange,提问作者Liam neesan

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 04:35:53