Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

asp.net core 2.0 mvc use Mysql in developpement and sql-server in production

$
0
0

Hello,

I want to work with mysql on my local computer and ms 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())


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>