Error occurred while access Microsoft.Extensions.HostingServices. Could not parse JSON file c# entity-framework-core json visual-studio-2010


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?

12/15/2019 6:02:22 PM

Popular Answer

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

12/15/2019 6:14:38 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow