1

I have database define in App_Data folder. Is it possible to deploy my app with database included App_Data if folder? Or update azure db automatically? Or if it isn't possible what's the best way to update azure db manually?

2 Answers 2

4

first solution for you

if you work with the entity framework, you can do the direct update, in the first step you have to replace the DB connection string in Web.config:

 <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=OnlineAuctionDb;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\OnlineAuctionDb.mdf" providerName="System.Data.SqlClient"/>

by connection string of database in azure

<add name="DefaultConnection" connectionString="Data Source=xxxxxxx.database.windows.net,1433;Initial Catalog=database;User [email protected];Password=mypassword" providerName="System.Data.SqlClient"/>

after if you publish check this value "selected Run the code First Migrations" as you see in this picture

enter image description here

In the last step, you click on the Publish button

Second solution for you

you should get the SQL script from your local database and run it on your remote database . (don't forgot to change connection string in your web.config for test before publish )

Sign up to request clarification or add additional context in comments.

Comments

0

Go to your project directory, Open the *.csproj file and add the below code under the Project tag.

<ItemGroup>
   <Content Include="App_Data\*">
      <CopyToPublishDirectory>always</CopyToPublishDirectory>
   </Content>
</ItemGroup>

Then publish again, all the files under App_Data folder will be uploaded to azure.

We can also update our Azure Db in VS: Tutorial: Build an ASP.NET app in Azure with SQL Database

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.