What I have:
What I need:
Notes:
I'm running my migrations on my dev station with "dnx ef database update". I guess I can use the webapp PS console but... doesn't seems like the proper way.
I know I can generate a SQL script for the migration but this seems to be too manual.
I remember that the "Publish" wizard had option "Execute EF migrations" in the past. Can't see it now.
Entity Framework can be useful for getting up and running quickly with a database application, but when it comes to deployment, EF's built-in data migration feature doesn't inspire confidence.
Delete your Migrations folder. Create a new migration and generate a SQL script for it. In your database, delete all rows from the migrations history table. Insert a single row into the migrations history, to record that the first migration has already been applied, since your tables are already there.
It depends on who has control over the production DB (dev team or separate DBA team).
In a customer project that I worked on, each developer had their own copy of the DB, where they tested all their migrations. Once the application code and migration code got checked in, we used TeamCity as a CI server to deploy the website, update the staging DB, and run unit tests & integration tests.
We provided the SQL scripts (generated by EF) to the DBA team to run against the production DB. Our dev team never touched the production DB.
If you're allowed to update the production DB, you can do it yourself. But I would highly recommend inspecting and then running EF-generated scripts that you can roll back if necessary. Also, don't forget to back up the production DB as needed.
Since you want automation (and if you are comfortable with it), you can use your CI system to update your production DB, the way my team and I updated our staging DB.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With