Entity Framework Tricks
Deploying a database via EF Code First Migrations from the commandline
Here are some handy powershell tools for updating a database when using Entity Framework Migrations.
Normally I have EF setup so that the db is created or updated when the site (usually a web app in Azure these days) is first loaded via the application_start method in Global.asax but sometimes it's better to have it all setup when your site is first deploy.
This is a particularly good idea when you have lots of migrations and lots of data in the existing database before the deployment is preformed. I've had deployments fail because of large amounts of data and lots of migration changes in the past, due to connection timeouts.
This commands should work with EF4 and above.
#######Create or update a database with a connection string name
Update-database -StartUpProjectName {myproject} -ProjectName {myproject} -ConnectionStringName {myconnectionstringname}
Ensure that you have the database connection string in the app.config/web.config of the project you are referencing in the command.
#######Create or update a database with a connection string
Update-database -StartUpProjectName {myproject} -ProjectName {myproject} -ConnectionString {myconnectionstring}