How to Connect a Localdb from Visual Studio to the Published Azure Web App

How to upload Visual Studio SQL server LocalDB to Azure

You can migrate your on-premises database to Azure SQL database using SQL Server 2012(SQL Server 2017 and 2019 might face compatibility issues) and SQL Server Management Studio (SSMS).

Firstly, you need to attach your existing database with SSMS. Follow the link.

Follow the below steps in SSMS once your database attached.

  1. Right click on the database you want to migrate. Select Task and from dropdown options select Deploy Database to Microsoft Azure SQL Database

Sample Image


  1. Click on Next on pop-up window. On the very next window you will get options to connect your Azure SQL Server. Provide your Azure SQL server name, server credentials and click on Connect.

Sample Image


  1. Provide the database name you want to give in Azure SQL Server. Fill the Azure SQL Database settings as per your requirement. Click on Next.

Sample Image


  1. Lastly, you will get a summary of all the settings you have done. Click on Finish to migrate the database.
  2. Once your database migrated successfully, you will get summary with Operation Complete message. Click on close. Your database has been migrated.
  3. Check on your Azure Portal to check the migrated database.

Sample Image

How to publish localdb to Azure from Visual Studio 2017

Do you have a Azure SQL Database created where you would be publishing the DB. You can follow this article to publish the DB

How to publish a website with sql local db database to azure using visual studio 2013

Try this http://www.asp.net/mvc/overview/getting-started/database-first-development/publish-to-azure and let us know if you need more help. You will just need Visual Studio 2013.

How to connect to LocalDB in Visual Studio Server Explorer?

OK, answering to my own question.

Steps to connect LocalDB to Visual Studio Server Explorer

  1. Open command prompt
  2. Run SqlLocalDB.exe start v11.0
  3. Run SqlLocalDB.exe info v11.0
  4. Copy the Instance pipe name that starts with np:\...
  5. In Visual Studio select TOOLS > Connect to Database...
  6. For Server Name enter (localdb)\v11.0. If it didn't work, use the Instance pipe name that you copied earlier. You can also use this to connect with SQL Management Studio.
  7. Select the database on next dropdown list
  8. Click OK

Sample Image

Using a LocalDb MDF file on Azure

You can't use an .mdf file in App_Data, but you aren't forced to SQL Azure -- you can use SQL Server Compact. Deployment from LocalDB to Compact is easy if you are using Code First Migrations; otherwise you will have to migrate to SQL Server Compact before you deploy. If you decide to go with Compact you'll have to make sure the database engine gets deployed, and you can find instructions for that in this tutorial:

http://www.asp.net/mvc/tutorials/deployment/deployment-to-a-hosting-provider/deployment-to-a-hosting-provider-deploying-sql-server-compact-databases-2-of-12



Related Topics



Leave a reply



Submit