Export (0) Print
Expand All

Package/Publish SQL Tab, Project Properties

The Package/Publish SQL tab on the Properties page is a legacy method for specifying SQL Server database deployment settings.

NoteNote

This topic applies to Visual Studio 2012 and Visual Studio Express 2012 for Web. The topic covers features that are included in the latest Visual Studio Web Publish Update available as of June, 2013. Most of these features are also available in Visual Studio 2010 and Visual Web Developer 2010 Express when you install the Web Publish Update.

When you configure database publishing on the Package/Publish SQL tab, only initial deployment of a database is automated, and you have to configure incremental deployment of database updates manually by creating custom SQL scripts. When you configure database deployment in the publish profile instead, incremental database updates as well as initial database deployment are automated. For more information, see Web Deployment Overview for Visual Studio and ASP.NET.

The Package/Publish SQL tab should be used only when it has already been configured in legacy projects or when you can't configure database deployment in the publish profile. For example, if you're using Windows XP or Windows Server 2003 and your application does not use Entity Framework Code First Migrations, you can't configure database publishing in the publish profile. In that scenario, use the Package/Publish SQL tab.

When you create a publish profile in a project that has database deployment settings configured on the Package/Publish SQL tab, the Publish Web wizard displays a warning message.

Publish_Web_Settings_tab_with_Package_Publish_

If you want to use the settings on the Package/Publish SQL tab, do not click enable the new database publish settings improvements. If you click enable the new database publish settings improvements, the publish profile settings will take precedence and the Package/Publish SQL settings will be ignored. (If you click enable the new database publish settings improvements and decide afterward that you want to use the Package/Publish SQL settings, you have to create a new profile.)

To access this tab on the Properties Page

  1. In Visual Studio, open a Web application project.

  2. Right click the project name in Solution Explorer and select Properties (C#) or MyProject (Visual Basic) to display the Properties page.

  3. Click the Package/Publish SQL tab.

    Package/Publish SQL tab of Project Properties

    If you have installed the Publish Web wizard, and if no settings for the project have been entered yet on the Package/Publish SQL tab, the normal UI for this tab is replaced by a warning that this tab should not be used for new development. If you have to configure database deployment on the Package/Publish SQL tab, click Enable this page to see the UI shown in the illustration.

Configuration

Specifies the configuration type that the settings on this tab apply to. For example, you can specify package settings for a debug configuration (Debug) that differ from the settings for a production configuration (Release). When you select a configuration type, the settings that you specify are stored with that configuration type. If you want the same settings for all configurations, select All Configurations. You can create custom configuration types by selecting Configuration Manager from the Build menu.

Platform

Specifies the operating system type that the settings apply to.

Database Entries

Specifies a list of databases to deploy. The grid in this section contains one entry for each database to deploy. The Database Entry Details section lets you specify settings for the selected database.

Deploy column of Database Entries table

Specifies whether the selected database should be deployed. This is useful when you want to deploy a database only the first time that you deploy a Web project. In that case, after you deploy the application the first time, you can clear this check box and the database is not included when you redeploy the same project.

Name column of Database Entries table

Specifies a name that identifies a database that you want to deploy. If the database is represented by a connection string in the Web.config file, this value is typically the name of the connection string with a suffix such as "-Deployment" or "-Web.config".

The suffix "-Web.config" (for example, "ConnectionStringName-Web.config"), specifies that the connection string value in the Web.config file should be used for deployment. For more information, see Connection string for destination database later in this document.

Up/down arrow buttons

Lets you specify the order in which databases are deployed.

Import from Web.config

Finds connection strings in the Web.config file and enters their names into the Database Entries grid with "-Deployment" appended to them.

You can change the "-Deployment" suffix to "-Web.config" (for example, change "ConnectionStringName-Deployment" to "ConnectionStringName-Web.config") in order to specify that the connection string value in the Web.config file should be used for deployment. For more information, see Connection string for destination database later in this document.

Add

Adds a row to the Database Entries grid.

Remove

Removes a row from the Database Entries grid.

Connection string for destination database

Specifies the connection string to use to connect to the destination database during deployment.

This connection string is used only during deployment, not for the Web.config file in the deployed Web application, with the following exception. If the Name value for this database ends with "-Web.config Connection String" (for example, "ConnectionStringName-Web.config Connection String"), and if the part of the name that comes before the suffix "-Web.config Connection String" exists as a connection string name in the application Web.config file, the following rules apply:

  • If you leave this field blank, the connection string value in the Web.config file is used for deployment. If you specify a transform for the connection string, the transformed connection string is used for deployment.

  • If you enter a value in this field, the value that you enter is used for deployment and the destination Web.config file is updated to contain this value.

    NoteNote

    If you specify a database name that ends with "-Web.config Connection String" and you specify a transform for the same connection string, the transform is not used. The value that you enter in this field is used in the destination Web.config file.

Pull data and/or schema from an existing database

Specifies whether the deployment process should generate scripts (.sql files) that include commands that can re-create the source database schema in the source database, and optionally the data.

Connection string for the source database

Specifies the connection string to use for the source database.

Database scripting options

Specifies whether only the database schema, only the data, or both the schema and the data should be deployed to the destination database.

Scripts that are generated to deploy the schema include the complete database schema. There is no option to automatically generate scripts that only reflect schema changes after an initial deployment. The same is true for data. Scripts that are generated to deploy data include all the data in the database. There is no option to automatically generate scripts that only reflect changes to data that were made after an initial deployment.

By default, when the scripts run during deployment, they run in a transaction.

Database Scripts table

Specifies scripts that run in the destination database as part of the deployment process.

By default, custom scripts that you add here do not automatically run in a transaction. If you want to run them in a transaction, specify that in the scripts themselves. For information about how to set the Transacted attribute for a script, see How to: Edit Deployment Settings in the Project File.

Include column of Database Scripts table

Specifies whether the script that is indicated in the Script path column should run when the Web project is deployed. This is useful when you want to run some scripts only the first time a project is deployed.

Script path column of Database scripts table

Specifies the path of a script that must run in the destination database in order to deploy schema changes or data. (In the case of automatically generated scripts, there is no path for the script. Instead, a description of the script is displayed.)

Up/down arrow buttons

Lets you specify the order in which the scripts run during deployment.

Add Script

Lets you add a custom script. Both SQL script and SqlCmd script are supported. Custom scripts are scanned for SqlCmd variables, and these are automatically converted to installation-time parameters in the IIS Web Deployment Tool. For more information about SqlCmd scripts, see sqlcmd Utility.

Remove Script

Lets you remove a script.

Database Deployment Notes

Provides a location for you to enter free-form notes about deployment. This text is not used for any automated functions.

Show:
© 2014 Microsoft