Share via


How to: Prepare a Database for Deployment From a Command Prompt by Using VSDBCMD

You can deploy a database project from a command prompt on any computer that is running SQL Server. However, you must first copy the build output of your database project, the VSDBCMD utility, and the following files to the computer from which you want to deploy the project:

  • DatabaseSchemaProviders.Extensions.xml

  • Microsoft.Data.Schema.dll

  • Microsoft.Data.Schema.ScriptDom.dll

  • Microsoft.Data.Schema.ScriptDom.Sql.dll

  • Microsoft.SqlServer.BatchParser.dll

  • Sqlceer35en.dll

  • Sqlceme35.dll

  • Sqlceqp35.dll

  • Sqlcese35.dll

  • System.Data.SqlServerCe.dll

  • VSDBCMD.EXE

You can copy these files over a network connection or to a universal serial bus (USB) drive and then connect it to the computer from which you want to deploy the project. For more information about the context in which you might follow this procedure, see Build and Deploy Databases to a Staging or Production Environment.

Note

You can provide additional command-line arguments to customize the deployment. For more information, see Command-Line Reference for VSDBCMD (Deployment and Schema Import).

To copy the required files

  1. If the computer on which you want to run VSDBCMD does not have Visual Studio installed, then you must perform the following tasks:

    1. Install the .NET Framework 3.5 SP1. For more information, see the following page on the Microsoft Website: Install .NET Framework 3.5 SP1.

    2. Install SQL Server Compact Edition 3.5 SP1 (32-bit). For more information, see the following page on the Microsoft Website: Install SQL CE 3.5 SP1 (32-bit).

    3. Install the batch parser. You can install any one of the following products:

      • Install the Client Tools from the SQL Server Express setup. For more information, see the following page on the Microsoft Website: SQL Server Express.

      • Install the SQL Server Feature Pack. For more information, see the following page on the Microsoft Website: SQL Server Feature Pack.

    4. Add the registry key HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0 by performing one of the following tasks:

      • On Windows 7 orWindows Server 2008, open a command prompt and type the following command:

        reg add HKCU \Software\Microsoft\VisualStudio\9.0
        
      • On other operating systems, create a file named VS2008Key.reg that contains the following statements:

        Windows Registry Editor Version 5.00
        
        [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0]
        @=""
        

        Open a command prompt, navigate to the folder in which you created VS2008Key.reg, and type the following command:

        VS2008key.reg
        

      The key is added to the registry on your computer.

  2. Navigate to the %Program Files%\Microsoft Visual Studio 9.0\VSTSDB\Deploy folder, and copy the contents of that folder and any sub-folders.

  3. Navigate to the %Program Files%\Microsoft SQL Server Compact Edition\v3.5 folder, and copy the DLLs.

  4. Navigate to either of the following folders, replacing ProjectDrive, ProjectsFolder, SolutionName, and ProjectName with the appropriate values for your development environment:

    • ProjectDrive:\ProjectsFolder\SolutionName\ProjectName\sql\debug

    • ProjectDrive:\ProjectsFolder\SolutionName\ProjectName\sql\release

  5. Copy the contents of the folder.

    Note

    You should copy the build output to a subfolder so that you keep the files for a particular database deployment separate from the files for all deployments.

    Next, you generate a deployment script for the project.

To generate a deployment script from a command prompt

  • Open a Command Prompt window, and type the following command line:

    VSDBCMD /a:Deploy /cs:"connectionstring" /dsp:Sql /model:ProjectName.dbschema /p:TargetDatabase=targetDB /manifest:manifestFileName.dbmanifest /script:outputScriptFileName.sql
    

    For ProjectName, you specify the database project for which you want to generate a deployment script. For targetDB, you specify the name that you want to give the target database.

To deploy a database project from a command prompt

  • Open a Command Prompt window, and type the following command line:

    VSDBCMD /a:Deploy /dd /cs:"connectionstring" /dsp:Sql /model:ProjectName.dbschema /p:TargetDatabase=targetDB /manifest:manifestFileName.dbmanifest /script:outputScriptFileName.sql
    

    For ProjectName, you specify the database project that you want to deploy. For targetDB, you specify the name that you want to give the target database.

See Also

Concepts

Terminology Overview of Database Edition

Build and Deploy Databases to a Staging or Production Environment

Reference

Command-Line Reference for VSDBCMD (Deployment and Schema Import)

Change History

Date

History

Reason

June 2010

Added links to installation of prerequisites and steps to add the required registry key to address feedback on the content Wiki.

Customer feedback.