entity framework - Package Manger Console (Update-Database cmd) is always getting connectionString from appsettings.development.json -
aspnetcore_environment set "production" via project properties , via pmc & powershell
$env:aspnetcore_environment="production"
which confirmed pmc&powershell
get-childitem env:
pmc picking connectionstring appsettings.development.json guess startup.cs, key line being .addjsonfile($"appsettings.{env.environmentname}.json"
adds/overwrites settings based on environment
public class startup { public startup(ihostingenvironment env) { var builder = new configurationbuilder() .setbasepath(env.contentrootpath) .addjsonfile("appsettings.json", optional: false, reloadonchange: true) /*this line*/.addjsonfile($"appsettings.{env.environmentname}.json", optional: true); //other stuff } public void configureservices(iservicecollection services) { services.adddbcontext<acontext>(options => options.usesqlserver(configuration.getconnectionstring("connectiona"))); services.adddbcontext<bcontext>(options => options.usesqlserver(configuration.getconnectionstring("connectionb"))); //other stuff }
i've created appsettings.production.json in case defaulting. i'm bit stuck. looked @ https://github.com/aspnet/entityframeworkcore/issues/9623 followed , hasn't helped.
any ideas why package manger console picks connectionstring appsettings.development.json when run update-database -c bcontext
?
will accept answer gets pmc pick environment changes without having edit connectionstrings , forth
Comments
Post a Comment