I was trying to create a migration for an MVC ASP.NET Core 3.10 project using Visual Studio 2019. I got two errors:
- An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Could not parse the JSON file.
- 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:
- Rolling back to .NET Core 3.0
- Using a name other than "InitialCreate" for the migration.
- Installing EntityFrameworkCore.Design, EntityFrameworkCore.SQlite, EntityFrameworkCore.SQlServer, EntityFrameworkCore.Logging.Debug, EntityFrameworkCore.Tools through the NuGet Package Manager
- Restarting the computer and trying again
- 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?
It turns out that my appsettings.json was missing a closing curly brace. Adding that in fixed the problem.