TechBubbles Microsoft Technology BLOG

Deploying Database with ASP.NET Web application

 

Web applications can be deployed in two different ways one by using one-click publish or by using a Web deployment package. Usually we may want to deploy our database scripts that we used along with the application deployment. This post discusses the procedures to deploy the database along with web application in Visual Studio 2010.

Assume there is no database exist in destination and configure the below steps for first-time database deployment

1. Select the project in solution explorer and select the project for properties

2. Click the Package/Publish SQL tab in properties dialogue box as shown below

image

3. Select build configuration from the Configuration dropdown that you want to deploy. You can select debug or release or custom configuration that you have created in

4. Import the Database connection strings from the web.config by clicking Import button as shown below

image

It creates a row for each entry in the web.config file. Notice by default it appends the ‘- Deployment’ to each entry.

5. Select the database entry row in grid and enter the detail database information as follows. enter the connection string to use during the deployment

image

6. To generate the scripts from existing database then check the Pull data and/or schema from an existing database option. select the one of the following options from the drop down box when tick this check box

image

Schema Only – duplicates the database structures

Schema and Data- duplicates the both structure and data

Data Only- duplicates only the data in destination environment

7. If you want to add the custom database scripts during this deployment add them by using Add Script button

image

8. If the source and destination database is SQL AZURE then edit the pre-source element in the .project file as shown in the below

   1: <PublishDatabaseSettings>

   2:   <Objects>

   3:     <ObjectGroup Name="ApplicationServices-Deployment"

   4:       Order="1">

   5:       <Destination Path="" />

   6:       <Object Type="dbFullSql">

   7:         <PreSource Path="..." ScriptSchema="True" 

   8:           ScriptData="False"

   9:           CopyAllFullTextCatalogs="False" />

  10:         <Source Path="..." Transacted="True" />

  11:       </Object>

  12:     </ObjectGroup>

  13:   </Objects>

  14: </PublishDatabaseSettings>

9. Some times you may have to deploy the web application several times but not the database. In this case you can disable database deployment as shown below

image

10. Finally you can also add the notes for database deployment

image

Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud