5

I have two .NET unrelated projects. One is a Model (v. 2.2) and another is Web application (v. 3.0.0-preview7). I didn't have the problem with preview5, but now I have trouble running migrations against 2.2 project.

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)'.

As I said, with preview5 I don't have any problem. Is it something that changed between 5 and 7, and I need to make some corresponding changes? I didn't see anything in the release notes. Or it is simply a bug, and I just need to wait until next preview?

I don't get any errors on dotnet build or dotnet run; only on dotnet ef commands

9
  • Iirc they got rid of the standard JSON library in net core 3 and made it a nuget package. The migration docs to 3.0 mention this and which package to use. An alternative is to use the newtonsoft JSON nuget package in both projects.
    – gbjbaanb
    Aug 5, 2019 at 0:55
  • unfortunately, Microsoft.AspNetCore.Mvc.NewtonsoftJson only exists in 3.0; not in 2.2
    – Felix
    Aug 5, 2019 at 1:14
  • I'm not sure that's quite right, I use it in my 2.1 core project. It may be there's more than one newtonsoft JSON package. I'm not near a pc to check.
    – gbjbaanb
    Aug 5, 2019 at 1:27
  • yes - there are a number of Newtonsoft packages. I tried to add Newtonsoft.Json (that exists in 2.2) and it didn't make a difference. Upgrade page learn.microsoft.com/en-us/aspnet/core/migration/… mentions Microsoft.AspNetCore.Mvc.NewtonsoftJson - that one only exists in 3.0. Not a big deal; I'll stick with preview5 for now
    – Felix
    Aug 5, 2019 at 1:30
  • Bummer :-( There is a discussion about it on GitHub
    – gbjbaanb
    Aug 5, 2019 at 1:33

2 Answers 2

16

Okey, so I found the solution problem was that dotnet ef --version was not preview 7 in my case it was preview 6 so i updated dotnet tool update --global dotnet-ef --version 3.0.0-preview7.19362.6 and now it works.

6
  • Thanks, @Ignas. Glad you found a solution to your problem. However, the answer in Stack Overflow is supposed to be to the original question. stackoverflow.com/help/how-to-answer
    – Felix
    Aug 5, 2019 at 6:43
  • So it should fix your problem also?
    – Ignas
    Aug 5, 2019 at 7:05
  • First, as OP, states, I have preview7 and you had preview6. Second, my model is in .NET Core, and yours - in netStandard2.1(?). Your solution was to upgrade to preview7 that I had to begin with. So, obviously, you have a different problem that benefit from different solution.
    – Felix
    Aug 5, 2019 at 15:28
  • as I understand what is written in here learn.microsoft.com/lt-lt/ef/core/what-is-new/ef-core-3.0/… that they The EF Core command-line tool, dotnet ef, is no longer part of the .NET Core SDK, so could you check the version of ef command line tool, because my version of ef nuget was good
    – Ignas
    Aug 5, 2019 at 16:28
  • I've seen multiple variants of this problem with the same solution - from Preview 5o to 7 the JSON methods available in the SDK have changed. You can also install the correct SDK from the dotnet github. Ensure that all of your packages and tooling on your machine are on the same versions.
    – Ryanman
    Aug 12, 2019 at 22:10
0

For me the solution was to create a global.json file with the following content:

{
   "sdk": {
      "version": "2.2.402"
   }
}

as explained in Microsoft docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.