Reputation: 1474
I have an MVC 4 web application using code first migrations in EF5. Inside my solution, I have a Windows Azure Cloud Service project which has the MVC4 app added as a web role. This then publishes to a Cloud Services instance in Azure. I can publish without any problems and I have set up the correct web.config transforms so the deployed application is pointing to the correct Azure SQL database. The one thing I can't work out is how to get my code first migrations to run automatically when I publish - or if that's even possible publishing to Cloud Services.
After I've published the app, it will happily create the user-related databases but that's due to code in the InitializeSimpleMembershipAttribute explicitly doing that. Is it possible for me to have code first migrations run automatically when I publish to cloud services or will I need to write some code in my app specifically to do this?
Upvotes: 2
Views: 979
Reputation: 1474
I was initially looking into this for deploying my app to a UAT environment in Cloud Services. After reading up on this for a while, it would seem that the general consensus is not to use automatic migrations for deploying to UAT or production. Instead, I'll be using code-based migrations during development then when I want to publish my changes to UAT, I'll generate a script for the UAT database using the update-database -Script -ConnectionString "uatconnectionstringhere"
syntax.
If anyone does actually want to have them run automatically, details are here.
Upvotes: 2