This is how I am currently adding my DbContext in my ConfigureServices method in Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
.....
services.AddDbContext<MyDbContext>(options =>
options.UseMySQL(Configuration.GetConnectionString("DefaultConnection")));
.....
}
And my connection string is stored in my appsettings.json file, like this for example:
{
....
"ConnectionStrings": {
"DefaultConnection": "server=localhost;user id=root;password=root;database=mydb;sslmode=none"
}
....
}
If I want to switch which database is being connected, how do I make the "services.AddDbContext()" switch the database if it is "Development" vs. "Production" environments?