gpt4 book ai didi

c# - Entity Framework : Run EF Migrations for Previous Version in Net Core

转载 作者:行者123 更新时间:2023-12-03 14:42:17 36 4
gpt4 key购买 nike

我安装了 Net Core 3.1.1000。
现在我们正在尝试使用 EF Core 2.2.6 数据库以前的解决方案运行 ef 迁移,
运行以下时,收到以下错误。

dotnet ef migrations add InitialCreate

The application to execute does not exist: .dotnet\tools.store\dotnet-ef\2.2.6-servicing-10079\dotnet-ef\2.2.6-servicing-10079\tools\netcoreapp2.2\any\dotnet-ef.dll'.


我们如何解决这个问题?
如何直接指向DLL目标目录并执行?我听说重命名文件目录不是一个好主意。
我看到真正的 dll 位于这里:

....dotnet\tools.store\dotnet-ef\2.2.6\dotnet-ef\2.2.6\tools\netcoreapp2.2\any\dotnet-ef.dll


已经运行并安装了这个: dotnet tool install --global dotnet-ef

最佳答案

解决方案
要修复它,您应该遵循以下两个步骤。

  • 将 EF 工具安装为本地或全局工具。打开终端并运行:dotnet tool install --global dotnet-ef .

    From .NET Core v3, the EF tool is no longer part of the .NET Core SDK.

    Github issue #14016 /Microsoft Breaking Changes


  • 安装以前的 .NET Core SDK。 .NET Core v2.2

  • 重现此错误
    我创建了一个干净的虚拟机,我刚刚安装了 .NET Core v3。然后,我运行命令 dotnet ef migrations add InitialCreate正如你提到的。我收到以下错误: enter image description here
    于是我安装了之前的.NET Core SDK 版本(v2.2),问题解决了。
    推荐
    Microsoft does not recommend using .NET Core version 2.x.x .这些版本已达到使用生命周期,这意味着不再支持它。他们建议迁移到受支持的版本,例如 .NET Core 3.1。

    关于c# - Entity Framework : Run EF Migrations for Previous Version in Net Core,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62547067/

    36 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com