Deploy Visual Studio 2010 Database Project

前端 未结 3 2039
后悔当初
后悔当初 2021-02-14 08:23

I have a Visual Studio 2010 Database project, from which I want to generate a script that simply puts up this database to another machine. The problem is that i can\'t find a so

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-14 08:36

    Marks--

    You likely have already resolved this, but I thought I should answer your questions for the benefit of others.

    Yes, you can deploy from Visual Studio to different machines. You can also do it from the command line, using VSDBCMD. And you can create a WIX project to give a wizard for others to install it with.

    If you can connect to the target database from your dev PC, you can deploy to it. To do this:

    1. Select another Configuration from the Solution Configuration drop down. Normally, the Project will come with "Debug" and "Release" baked in. You can add another configuration to allow you to deploy to various targets by clicking "Configuration Manager."

    Solution Configuration drop down

    1. Right-click your Project and select 'Properties', or simply double-click Properties under the project.
    2. Click the Deploy tab. Notice that the Configuration: drop-down shows the same selected configuration as "active."
    3. Change the Deploy Action to "Create a deployment script (.sql) and deploy to the database."
    4. Next to Target Connection String, click "Edit" and use the dialog to create your deployment connection to the target database.
    5. Fill in the Target database name, if different.
    6. For each Deployment Configuration (e.g., Debug, Release, etc.), you will probably want a separate Deployment configuration file. If you click "New," you can create one for the current configuration. The new file will open, and you can check and uncheck important things about the deployment.

    The .sqldeployment file

    1. Note: If you check Always re-create the database, the script will DROP and CREATE your database. You will lose all your data on the target! Be careful what you select here. Most people leave that unchecked for a Production target. I check it for Development or Local because I want a fresh copy there.
    2. Save your changes to the file and to Properties.
    3. To deploy to the target, be sure to select the correct Configuration. Click Build/Deploy [My Database Name]. You probably should experiment with this so you are familiar with how it works before trying it on a live environment.
    4. Good practices: build a similar environment to production ("Staging") and deploy there first, to test the deployment, and always back up the database before deploying, in case something goes wrong.

    For more info, please see:

    • Working with Database Projects
    • Walkthrough: Put an Existing Database Schema Under Version Control
    • Visual Studio 2010 SQL Server Database Projects

提交回复
热议问题