结合.NET Core 2.2和3.0项目

Fel*_*lix 2 entity-framework-core .net-core

我有两个.NET不相关的项目。一个是模型(v。2.2),另一个是Web应用程序(v。3.0.0-preview7)。我没有Preview5的问题,但是现在我无法对2.2项目运行迁移。

C:\>dotnet ef --help
System.MissingMethodException: Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Method not found: 'System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.IO.Stream, System.Text.Json.JsonReaderOptions)'.
Run Code Online (Sandbox Code Playgroud)

就像我说的,使用Preview5我没有任何问题。它在5到7之间变化了吗,我需要进行一些相应的更改?我没有在发行说明中看到任何内容。还是仅仅是一个错误,我只需要等到下一个预览?

我在dotnet build或上没有任何错误dotnet run。仅在dotnet ef命令上

小智 11

Okey,所以我发现解决方案问题是dotnet ef --version在我的情况下不是预览版7,所以我进行了更新 dotnet tool update --global dotnet-ef --version 3.0.0-preview7.19362.6,现在可以正常工作了。


Fel*_*lix 0

对我来说,解决方案是创建一个global.json包含以下内容的文件:

{
   "sdk": {
      "version": "2.2.402"
   }
}
Run Code Online (Sandbox Code Playgroud)

Microsoft 文档中所述