0

I'm currently developing an ASP.Net MVC 5. The problem is, I have always coded the websites and handed them over to other people who managed the deployment and maintenance. I have never been on the other side of the production and now I have to be. I have read some articles for ASP.Net MVC 3 but since I am creating this project with MVC 5, I was wondering what I should do in situations where the models need some changes. For instance:

  • I rename field or column
  • Add another field to the model with acceptable default values (maybe even null)
  • Remove a field
  • ...

1 Answer 1

1

You should be able to generate the script needed to update your database. See this post for more information. Basically it says:

Run the Update-Database command but this time specify the –Script flag so that changes are written to a script rather than applied.

Open your package manager console (Tools > Library Package Manager > Package Manager Console), target your migrations project, and run "Update-Database -Script".

Then take the script and run it against your production / staging / testing / whatever environment.

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome. Just one question. Currently, I'm using the Database.SetInitializer(new Ghazanet.Infrastructure.CustomInitializer()); to re-initialize the DB whenever I change the models. When should enable and build theinitial migration?
See stackoverflow.com/questions/10848746/… and the related links in that post for more information

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.