I figured it out. This mostly came about because I accidentally deleted the database that Identity was using and I needed to figure out how to get it back.
Apparently there’s nothing wrong with my connection string the way it is. I just needed to go into the package manager and type these commands in this order:
Add-Migration init -Context PartsDbContext
Update-Database -Context PartsDbContext
I found this out because that is what I had to do to get my ApplicationDbContext working again and it turns out that this step is done for you when you create a new MVC Core Web Application in Visual Studio using Individual User Authentication.
So basically the steps for adding more DbContexts is to:
- Create a DbContext Class
- Create a Connection string for that DbContext in appsettings.json
- Add the DbContext to your configured services in Startup.cs
- Setup the DbContext in the controllers that will use it.
- Open the package manager and run the 2 lines above. (if “-Context” doesn’t work try “–context”
- Run your program and let EntityFrameworkCore take care of the rest.