If you are using Entity Framework Migrations you can simply use the Database Initializer MigrateDatabaseToLatestVersion
. On your development machine you perform all your work with the migrations, testing, etc, and when you are happy with the result, send the working Migrations to the server with your updated code base, then restart the server. The context does the rest.
If you are deploying your application you may want it to automatically upgrade the database (by applying any pending migrations) when the application launches. You can do this by registering the MigrateDatabaseToLatestVersion database initializer. A database initializer simply contains some logic that is used to make sure the database is setup correctly. This logic is run the first time the context is used within the application process (AppDomain).