Bagikan melalui


How to: Build a Database Project to Generate a Compiled Schema (.dbschema) File

After you change the database project, you must prepare the build script to either create or update the target. You specify a new or existing database as the target by configuring build settings in the project properties. After you configure those settings, you can build the database project, which assembles any pre-deployment and post-deployment scripts together with the object definitions from the database project. After you prepare the database build script, you can deploy it to the target's database server.

You can prepare a build script to create a database without having permissions on a target database or server because you do not have to access the database to build the database project for a new deployment. To prepare an update script, you must have permission to access the server, the database, and the database objects in the target.

To prepare a database build script in Visual Studio

  1. In Solution Explorer, click the node for the database project for which you want to prepare a build script.

  2. On the Build menu, click Build DatabaseProject.

    The object definition scripts and pre-deployment and post-deployment scripts are assembled.

To prepare a database build script from the command line

  1. Open the Visual Studio Command Prompt window, and locate your project directory.

    Note

    To open a Visual Studio Command Prompt, open the Start menu, click All Programs, click Microsoft Visual Studio 2010, click Visual Studio Tools, and click Visual Studio Command Prompt (2010).

    By default, projects are created in My Documents/Visual Studio 2010/Projects.

  2. At the command prompt, type the following command line to generate a build script where DatabaseProject is the name of your project:

    MSBuild /t:Build Path\DatabaseProject.dbproj

    Note

    MSBuild.exe must be on the path that your PATH environment variable specifies. For more information about command line syntax for generating build scripts, see An Overview of Database Build and Deployment.

    The object definitions in your database project and pre-deployment and post-deployment scripts are assembled. Results such as the following appear:

    ------ Build started: Project: ProjectName, Configuration: Debug Any CPU ------

    Verifying project state.

    Finished verifying project state.

    ProjectName -> ProjectDrive:\Documents and Settings\UserName\My Documents\Visual Studio 2008\Projects\SolutionName\ProjectName\sql\ProjectName.dbschema

    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

See Also

Tasks

How to: Deploy Changes to New or Existing Databases

Walkthrough: Create and Deploy a New Version-Controlled Database

Walkthrough: Deploy Changes to an Existing Version-Controlled Database

Concepts

An Overview of Database Build and Deployment

An Overview of Database Project Settings

Build and Deploy Databases to an Isolated Development Environment

Build and Deploy Databases to a Staging or Production Environment