The docs mention that there is no support in 2.0 for passing in custom environment variable, but EF core 1.0 supported the --environment argument. I kind of feel that this feature should still be supported in EF Core 2.0.
Currently, I am deploying multiple applications to the same machine, but different versions on the same machine. I am using Puppet to automate some of the deployment process and end up with websites in IIS such as Company.Project.[env]
. Where env
is something like .dev, .test, .uat each running under a seperate AppPool etc. Now, with ASP.NET Core 2.0 I can apply an <environmentVariable
> to the web.config for each deployed aspnet core website and that environment variable in the web.config
takes priority over any machine environment variable of ASPNETCORE_ENVIRONMENT
. During puppet deployment it inserts the correct value in the web.config for the ASPNETCORE_ENVIRONMENT variable, this makes perfect sense to me and allows each deployed app to still be bootstrapped correctly and load in the correct appsettings.[environment].json
file.
Now, with EF Core 2.0, I cannot do this. I was planning on deploying a separate database project for each environment and suffixing each deployed package with the environment name just like how I am doing so with the websites and was planning on somehow passing in an --environment to run any dotnet ef
commands and make them read the correct appsettings.[environment].json
file which would have the correctly targeted database environment connection string to run migrations against.
If ASPNET Core websites support an <environmentVariable
> in the web.config
which allows for multiple projects to be deployed to the same machine consuming unique environment variables. Then I feel like EF Core should support passing in --environment.
Since this is no longer supported, what would be the best way to deploy an application multiple times on the same machine but also run dotnet ef
commands to target a specific appsettings.[environment].json to ensure the ef command uses a specific connection string in the deployed project and then run the migrations on the correct database on that machine.
ASPNETCORE_ENVIRONMENT
environment variable. I'm not aware of the other way. See: docs.microsoft.com/en-us/aspnet/core/fundamentals/environments I think you should open an issue for that on github so you will get the most satisfying answer. – Konrad