Coding

Quick Tip: Manually Run EF Migrations on External Databases

Entity Framework migrations are a great thing. They’ve made my development life a LOT easier. Automated migrations can cause problems, especially on a project with multiple developers involved. For that, we use manual migrations through the Package Manager Console.

But how do you manually run these migrations against your test (or live) server when your deployment tool doesn’t run them? If you have access to the database in question, you can add the ConnectionString and ProviderName parameters at the Package Manager Console prompt and make life a lot easier:

Update-Database -ConnectionString "MY_CONNECTION_STRING" -ConnectionProviderName "System.Data.SqlClient"

You can pull your connection string direct from your web.config transform, no special “magic” needed.

Enjoy!

quick_tip_banner

Advertisements

What are your 10 bits on the matter? I want to know!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s