Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error occurred while access Microsoft.Extensions.HostingServices. Could not parse JSON file

I was trying to create a migration for an MVC ASP.NET Core 3.10 project using Visual Studio 2019. I got two errors:

  1. An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Could not parse the JSON file.
  2. 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 object in its constructor and passes it to the base constructor for DbContext.

I assume the first one is the problem, since I already have my DbContext set up as the second one asked.

What I've tried so far:

  1. Rolling back to .NET Core 3.0
  2. Using a name other than "InitialCreate" for the migration.
  3. Installing EntityFrameworkCore.Design, EntityFrameworkCore.SQlite, EntityFrameworkCore.SQlServer, EntityFrameworkCore.Logging.Debug, EntityFrameworkCore.Tools through the NuGet Package Manager
  4. Restarting the computer and trying again
  5. Quadruple-checking that Startup.cs had my DbContext added, and that my DbContext has the constructor set up to take a DbContextOptions in its constructor, passing the input to the base constructor

What should I do about the first error?

like image 940
Tespy Avatar asked Dec 15 '19 17:12

Tespy


1 Answers

It turns out that my appsettings.json was missing a closing curly brace. Adding that in fixed the problem.

like image 65
Tespy Avatar answered Sep 30 '22 06:09

Tespy