donet ef migration errors

Simon Leung
Simon Leung used Ask the Experts™
on
Try to run dotnet ef migration but fails. Any idea ?

C:\Projects\slivrr>dotnet add package Microsoft.EntityFrameworkCore --version 3.0.0-preview.18572.1
  Writing C:\Users\tonyleung.abc\AppData\Local\Temp\tmp6309.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore' into project 'C:\Projects\slivrr\slivrr.csproj'.
info : Restoring packages for C:\Projects\slivrr\slivrr.csproj...
info : Package 'Microsoft.EntityFrameworkCore' is compatible with all the specified frameworks in project 'C:\Projects\slivrr\slivrr.csproj'.
info : PackageReference for package 'Microsoft.EntityFrameworkCore' version '3.0.0-preview.18572.1' updated in file 'C:\Projects\slivrr\slivrr.csproj'.
info : Committing restore...
info : Writing assets file to disk. Path: C:\Projects\slivrr\obj\project.assets.json
log  : Restore completed in 220.26 ms for C:\Projects\slivrr\slivrr.csproj.

C:\Projects\slivrr>dotnet add package Microsoft.EntityFrameworkCore.Design --version 3.0.0-preview.18572.1
  Writing C:\Users\tonyleung.abc\AppData\Local\Temp\tmpAF16.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.Design' into project 'C:\Projects\slivrr\slivrr.csproj'.
info : Restoring packages for C:\Projects\slivrr\slivrr.csproj...
info : Package 'Microsoft.EntityFrameworkCore.Design' is compatible with all the specified frameworks in project 'C:\Projects\slivrr\slivrr.csproj'.
info : PackageReference for package 'Microsoft.EntityFrameworkCore.Design' version '3.0.0-preview.18572.1' updated in file 'C:\Projects\slivrr\slivrr.csproj'.
info : Committing restore...
info : Assets file has not changed. Skipping assets file writing. Path: C:\Projects\slivrr\obj\project.assets.json
log  : Restore completed in 167.02 ms for C:\Projects\slivrr\slivrr.csproj.

C:\Projects\slivrr>dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 3.0.0-preview.18572.1
  Writing C:\Users\tonyleung.abc\AppData\Local\Temp\tmpF21A.tmp
info : Adding PackageReference for package 'Microsoft.EntityFrameworkCore.SqlServer' into project 'C:\Projects\slivrr\slivrr.csproj'.
info : Restoring packages for C:\Projects\slivrr\slivrr.csproj...
info : Package 'Microsoft.EntityFrameworkCore.SqlServer' is compatible with all the specified frameworks in project 'C:\Projects\slivrr\slivrr.csproj'.
info : PackageReference for package 'Microsoft.EntityFrameworkCore.SqlServer' version '3.0.0-preview.18572.1' updated in file 'C:\Projects\slivrr\slivrr.csproj'.
info : Committing restore...
info : Assets file has not changed. Skipping assets file writing. Path: C:\Projects\slivrr\obj\project.assets.json
log  : Restore completed in 168.01 ms for C:\Projects\slivrr\slivrr.csproj.

C:\Projects\slivrr>dotnet ef migrations add InitialCreate
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)'.

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dirk StraussSenior Full Stack Developer
Distinguished Expert 2017

Commented:
Have you added/referenced the Namespace: System.Text.Json. Refer to JsonDocument.Parse Method

Author

Commented:
Modify the code and still return an error.

System.InvalidOperationException: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
TimepieceContext.cs
Startup.cs
Senior Full Stack Developer
Distinguished Expert 2017
Commented:
Have a look at this article: No database provider has been configured for this DbContext. See the comments for the first accepted answer about adding the following to the Startup.cs
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); 
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();

Open in new window

Author

Commented:
https://stackoverflow.com/questions/55974734/ef-core-tools-not-working-on-dotnet-core-3-preview-4

Fixed it through the attached link. Thx for response and information.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial