I want to work with mysql on my local computer and SQL Server on production server.
Here is what I've tried to do in Startup.cs:
I have two methods:
public void ConfigureServices(IServiceCollection services)
{
}
and
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
}
Unfortunately, I have to put one of this lines in ConfigureServices method:
services.AddDbContext<DbContext>(options => options.UseMySQL("..."));
or
services.AddDbContext<pluginwebContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
But ConfigureServices does not provide env parameter so I cannot test with:
if (env.IsDevelopment())
envas a field in the class to give you access to it. it can be set in the constructor