f0rt
f0rt

Reputation: 1931

What is the best way to run EF migration on production server?

What I have:

What I need:

Notes:

Upvotes: 10

Views: 1974

Answers (1)

Shahed C - MSFT
Shahed C - MSFT

Reputation: 2881

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!

Upvotes: 2

Related Questions