Share via


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

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.Data.Schema.Sql.dll

  • Microsoft.Data.Schema.Utilities.dll

  • Microsoft.SqlServer.BatchParser.dll

  • Sqlceer35en.dll

  • Sqlceme35.dll

  • Sqlceqp35.dll

  • Sqlcese35.dll

  • System.Data.SqlServerCe.dll

  • VSDBCMD.EXE

Important

To use VSDBCMD.EXE on a computer on which you have not installed Visual Studio, you must install the version of Microsoft.SqlServer.BatchParser.dll that matches your version of SQL Server. For SQL Server 2008, that file is installed when you install any of the following software:

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.

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

Important

You cannot use VSDBCMD to deploy a Data-tier Application Component project. For more information about how to deploy Data-tier Application Components, see Deploying Data-tier Application Packages on the Microsoft Web site.

Special Requirements for 64-bit Operating Systems

If you want to deploy by using VSDBCMD.EXE on a computer that has a 64-bit operating system, you must install both the 32-bit and the 64-bit versions of the SQL CE assemblies listed earlier in this topic. To install the necessary files, see the following page on the Microsoft web site: Download details: Microsoft SQL Server Compact 3.5 Service Pack 2 for Windows Desktop.

Note

You do not have to deploy from your production server. You can use any computer from which you can connect to the target server and database, such as a staging computer.

BadImageFormatException

If a BadImageFormatException occurs when you run VSDBCMD.EXE, you can resolve the issue if you install Microsoft .NET Framework 4. For more information, see the following page on the Microsoft web site: Download details: Microsoft .NET Framework 4 (Standalone Installer).

To copy the required files

  1. Navigate to the Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy folder, and copy the contents of that folder and its subfolders.

    Note

    The Extensions subfolder contains DatabaseSchemaProviders.Extensions.xml, without which deployment will fail.

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

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

  4. 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 /dd:- /a:Deploy /manifest:manifestFileName.dbmanifest
    

    The /dd:- option ensures that a script is generated, but no deployment occurs. The deployment manifest provides the other settings that you could otherwise specify on the command line.

To deploy a database project from a command prompt

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

    VSDBCMD /a:Deploy /dd:+ /manifest:manifestFileName.dbmanifest
    

    The deployment manifest provides the other settings, such as target database name, connection string, and so on, that you could otherwise specify on the command line.

See Also

Reference

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

Concepts

Build and Deploy Databases to a Staging or Production Environment

An Overview of Database Project Settings