[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
A Visual Studio 2010 Web package can package an application's dependencies on SQL Server databases. As part of the package definition, you provide the connection string for your source database. When you create the Web package, creates SQL scripts for the database schema and optionally for the data, and then adds these to the deployment package. You can also provide custom SQL scripts and specify the sequence in which they should run on the deployment server. At deployment time, you provide a connection string that is appropriate for the target server. The deployment process then uses this connection string to run the scripts that create the database schema and add the data.
For more information about deployment packages, see ASP.NET Web Application Projects Deployment Overview.

Prerequisites
Some of the functionality in Web packaging may not work for Web application projects created by using earlier versions of Visual Studio. If you want to package an existing Web application project that was created in an earlier version of Visual Studio, back up the existing project, and then open the project in Visual Studio 2010. You will then be prompted to convert the project to a Visual Studio 2010 project.

Creating a Web Application and Database to Deploy
You can package an existing Web application that uses a database or create a new one to package. If you use an existing project which was created in an earlier version of Visual Studio, you will be prompted to upgrade the project to a Visual Studio 2010 project when you open the project.
To create a new Web application project and database to package
Select Project from the File menu. The New Project dialog box appears.
Select Web Node and then select ASP.NET Web Application Project. This action creates a new Web application. This basic project can then be packaged.
Right-click the App_Data folder. Select Add, and then select New Item.
In the Add New Item dialog box, select Data from the Categories list.
Select SQL Server Database from the templates window. Enter a name for the database, and then click Add. An empty database is created in the App_Data folder.

Specifying the Database to be included in a Web Package
You use the project's Properties window to specify the database and any scripts associated with the database.
The following illustration shows the Publish - SQL tab that is used to specify a database to be included with a Web package.
The Publish - SQL tab of the Properties window
.png)
To specify a database using the Properties window
Double click the Properties folder.
In the Properties window, select the Publish - SQL tab.
In the Configuration list, select the Debug configuration setting.
Click Add Data Connection.
Enter a name by which you want to identify the database in the Connection Name field. New fields are shown when you complete the name of the connection string.
Select the Automatically script database check box.
Directly under the check box, click the ellipsis button (…) next to the Connection String field in the Source section.
In the Source Connection String dialog box, type (local) in the Server name field.
In the Log on to the server section, click Use Windows Authentication.
In the Connect to database section, select Select or enter a database name and enter the name of the database you created. If you did not rename the database, the default name of the database created is Database1.mdf. Click OK.
On the Properties page, in the Source section, click Schema only.
Click the ellipsis button (…) button next to the Connection String field at the bottom of the window in the Destination section.
In the Destination Connection String dialog box, enter the server name and logon credentials of the database server where you would like to deploy the database. Be aware that if you are deploying to a hosted server then this connection string may be provided to you by the hoster. If you are deploying to a local server, the database administrator would give you the connection string.
Click OK. The connection string appears in the Connection String field.
Save the Properties page settings.

Creating the Web Package
Because this walkthrough is intended to show you only how to include a SQL Server database together with a Web package, you will not enter additional settings for a Web package. For more information about additional settings for a Web package, see Walkthrough: Web Packaging For IIS Deployment.
To create and view a Web package
In the Solution Explorer, right-click the Web application name and select Package, and then select Create Package.
When the package creation has completed, open the obj folder, open the Debug folder, and then open the Package folder. The package (either a .zip file or an archive folder) will be located in this directory and the SQL scripts created from your source database will be present inside the package.

See Also
Concepts
Other Resources
Walkthrough: Deploying a Web Package to a Remote or Third-Party Server