Thursday, 8 August 2013

Code first migrations when publishing web role to Azure Cloud Services

Code first migrations when publishing web role to Azure Cloud Services

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?

No comments:

Post a Comment