Eriendel
Eriendel

Reputation: 969

How to migrate SQL DB onto Azure SQL DB with EF DB First

I want to easily migrate my existing DB to Azure hosting. In my project I use Entity Framework DB First. Is there any lessons or examples of how to do that?

Upvotes: 0

Views: 526

Answers (2)

amhed
amhed

Reputation: 3659

You can also do this:

  • Go to the Azure Management portal, click on "Databases", choose your server, click on "Configure" and give permission to your local IP to connect directly to the DB.
  • Go back to your solution, and change the entry for the connection string on your web.config file to point to the azure server.
  • Run "database-upgrade" from the package manager (powershell) command line to perform all migrations on the server

You can also configure your publishing profile to include the migrations on each deploy for azure. Take a look at a previous question on that subject here

Upvotes: 1

Eoin Campbell
Eoin Campbell

Reputation: 44268

What database are you using Locally. if you're using SQL2012 or (2012 Express) there is tooling built into Management studio to allow you to Import/Export between local and azure.

Have a look at Import Data Tier Application & Export Data Tier Application for generating BACPAC files (SQL Azure equivalent of a .bak). That'll allow you to get your initial DB into SQL Azure. And to get backups back to your local environment in future.

Once you've done that, take a look at the Fluent Migrator for pushing DB First schema changes you develop locally out to your QA & Produciton Databases in azure.

Upvotes: 3

Related Questions