When I am debugging my ASP.NET MVC 5 project on visual studio, entity framework creates a ".mdf" file. Now I need to download my app's database hosted on azure to debug locally. How can I do that?
Asked
Active
Viewed 183 times
1 Answers
2
Please read this article Export an Azure SQL database to a BACPAC file. Here you will find how to export your database from Azure.
After that in SQL managment studio use this answer How to restore Azure SQL Database Bacpac Local (import Azure database to your local machine) and then please use your local database which was taken from Azure

Sergiy Divnych
- 149
- 2
- 13
-
But can I use the bacpac file as the database? Or should convert it to mdf first? – Gilliano Menezes May 18 '18 at 13:54
-
@GillianoMenezes when you are importing bacpac file in SQL managment studio it converts to such format as you need to have – Sergiy Divnych May 18 '18 at 13:58
-
@GillianoMenezes [link](https://learn.microsoft.com/en-us/sql/relational-databases/data-tier-applications/import-a-bacpac-file-to-create-a-new-user-database?view=sql-server-2017) here also you can find full instruction how to import bacpac file – Sergiy Divnych May 18 '18 at 14:00
-
@GillianoMenezes Have you tryed to import bacpac file in SQL managment studio? – Sergiy Divnych May 18 '18 at 14:21
-
In the last link I found instructions to import a bacpac file to create a new database on Azure. But what I need is to use the data to debug locally on visual studio. Is there any other way? – Gilliano Menezes May 18 '18 at 14:41
-
1@GillianoMenezes Open SQL managment studio, Right click on the Connection > Databases node and select "Import Data-tier application...", Select "Next" on the introduction step, Browse, or connect to a storage account where backups are kept and this will import Azure database to your local machine. When you will have that database locally, you can connect to that database changing your connection string to local database in web.config and debug locally on visual studio – Sergiy Divnych May 18 '18 at 14:49
-
1@GillianoMenezes Connection string if you use SQLEXPRESS `
` and if you use localdb ` ` – Sergiy Divnych May 18 '18 at 14:55 -
@GillianoMenezes If it has helped you (eventually) please don't forget to mark it as the answer, thanks! – Sergiy Divnych May 21 '18 at 14:03