Del via


Package/Publish SQL Tab, Project Properties

The Package/Publish SQL tab on the Properties page of the Web application project lets you specify settings for how to deploy a SQL Server database together with the Web application project. As part of the settings, you can specify custom scripts that run when the Web package is deployed. For more information about how to deploy a Web project, see ASP.NET Deployment Content Map.

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.

UI Elements

  • 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.

      Note

      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.

See Also

Concepts

ASP.NET Deployment Content Map