0

I'm using Asp.Net Boilerplate (3.8.1) with Entity Framework Core. I have 3 environments (dev, staging, production) so I have 3 appsettings.json in my .Web.Host project (each with default ConnectionStrings pointing to their respective database).

If I launch Update-Database -> my Dev Database (specified in appsettings.json) is correctly updated

Starting with EFCore 2.0, you have to set en env variable to update the staging database (see ef core don“t use ASPNETCORE_ENVIRONMENT during update-database).

I tried that (setting the env variable to staging) and it did not work with my Asp.Net Boilerplate project. I tried quickly with a simple EFCore and setting the environment does not seem to work.

Is there an other way to do that ?

seblucas
  • 825
  • 1
  • 7
  • 17

1 Answers1

0

The way I go about doing this is this: if there are schema changes with a release, then I use the dotnet cli tooling to export the migration scripts.

So For example:

dotnet ef migrations script -i -o "C:\temp\mychanges.sql"

It's an idempotent script that only applies migrations if they haven't already been applied to the database. This is useful if you are deploying to multiple databases that may each be at a different migration.

jazb
  • 5,498
  • 6
  • 37
  • 44