Reputation: 3365
How do I update the database for production? I've moved the connection string secrets out of the application. Our CI/CD pipeline handles the token replacement within the connection string "template" that remains in the appsettings, and developers won't have production database access.
I had expected to use automatic migrations, only to discover today that Microsoft eliminated that for EF Core.
Will I have to, every time, temporarily overwrite the connection string that normally specifies my local dev copy of the database? It seems that way, but it also seems very janky process to me, so I wonder if I'm missing something.
Upvotes: 2
Views: 251
Reputation: 205799
There seem to be a confusion of what automatic migration means.
Migrations consist of two parts:
Migration generation in turn could be two types:
Add-Migration
command). The auto-generated code can be modified. Modified or not, the migration is stored along with the application code.Regardless of how migrations are generated, they can be applied at design time using the tools (Update-Database
command) and/or at runtime.
What EF6 supports and EF Core have removed is the auto-generation. EF Core migrations cannot be generated at runtime - they must be generated at design time and stored with the application code.
Applying them at runtime is achieved with Migrate
method called from some application startup point:
dbContext.Database.Migrate();
For more info, see Migrations and Apply migrations at runtime EF Core documentation topics.
Upvotes: 3