JonPSmith / EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
https://www.thereformedprogrammer.net/new-features-for-unit-testing-your-entity-framework-core-5-code/
Other
352 stars 53 forks source link

AppSettings.GetConfiguration doesn't allow for environmental variable overrides #53

Closed crazyjackel closed 1 year ago

crazyjackel commented 1 year ago

Inside various pipeline based software, it is necessary to allow configuration to be overridable by Environmental Variables. as a means to help match up services. Inside AppSettings.GetConfiguration, would it be possible to add environment variables such that "ASPNETCORE_ConnectionStrings__PostgreSqlConnection" can override the connection string?

JonPSmith commented 1 year ago

Hi @crazyjackel,

Have you though about adding a stage in your pipeline that overwrites the appsetting.json file in your test project with the connection strings set to the databases you want to use in the pipeline?

Looking at the code it can't be easily changed. You could copy the code for handling a PostgreSql database and change how it gets the database string.

crazyjackel commented 1 year ago

would adding .AddEnvironmentalVariables("ASPNETCORE_") to the configuration builder at GetConfiguration not work?