Database Deployment with Visual Studio 2010

by Jonathan on May 27, 2010

Microsoft Visual Studio

I have been exploring some of the features of Visual Studio 2010 that are useful to DBAs and Database Developers. Today’s topic is Database Deployment. Software developers have been using the deployment tools in Visual Studio for some time, however, the addition of database deployment gives database professionals the ability to systematically deploy their projects to a multiple environments.

Every enviornment can be configured to have a different configuration. For example, in my development environment I tell VS2010 to build the solution script and then deploy it to the server. In my production environment I tightly control what and when scripts are deployed to the database. When I am building the solution for my production environment I configure VS2010 to build the deployment script and put it into a folder. This allows me to schedule the script to go into production when I choose.

We are going to walk through setting up a database project and configuring the project for deployment. Open or create a database project. Right click on the top of the project in the solution explorer, at the top of the explorer tree. Select ‘Properties’ from the menu. This will open the project properties window. The deploy tab of the project properties will allow us to configure the deploy settings.

alt text

There are three main settings that we will focus on. The first is the configuration. Configuration is the setting that allows us to change the behavior for different environments. In this example project I have set the configuration to be debug. The debug configuration is my test environment and where I want to allow VS2010 to automatically deploy the solution to the server automatically.

The second setting we are going to look at is the ‘Deploy Action’. The default setting is ‘Create Deployment Script (.sql). Leaving this set on the default means that a deployment .sql script will be crated but not deployed to my database. This gives database professionals the flexibility to deploy the script via SSMS, scheduled job, etc. In the case of my test environment I want to use ‘Create a deployment script (.sql) and deploy to the database’. This will run the deployment script against my test environment every time I select deploy from the build menu.

The final setting that I want to highlight is the Target Connection Setting. This can be different with each configuration setting allowing me to connect to different SQL Servers and/or different databases for the environment I am deploying to.

What have your experiences with deployment in Visual Studio 2010. We would love to hear about them.

  • Pingback: Tweets that mention Database Deployment with Visual Studio 2010 | Jonathan Gardner -- Topsy.com

  • Peter

    If you’ve done any branching of DB Projects, I’d love to see that. That’s going to be a pretty big need for us.

    • http://www.jonathanagardner.com Jonathan Gardner

      Peter, are you talking about source control branching? I plan on going over source control in a future topic, to be released very soon. I will make it a point to look at branching for you. Any other pain points that you would like for me to cover?

  • Peter

    If you’ve done any branching of DB Projects, I’d love to see that. That’s going to be a pretty big need for us.

    • http://www.jonathanagardner.com Jonathan

      Peter, are you talking about source control branching? I plan on going over source control in a future topic, to be released very soon. I will make it a point to look at branching for you. Any other pain points that you would like for me to cover?

  • http://www.aaronlowe.net Aaron Lowe

    I love VSDBPro and have enjoyed it since it came out for VS2005. I have made a few posts discussing it over at http://www.aaronlowe.net/archive/category/vsdbpro/ if you want to check them out.

    • http://www.jonathanagardner.com Jonathan Gardner

      I will check them out.

  • http://www.aaronlowe.net Aaron Lowe

    I love VSDBPro and have enjoyed it since it came out for VS2005. I have made a few posts discussing it over at http://www.aaronlowe.net/archive/category/vsdbpro/ if you want to check them out.

    • http://www.jonathanagardner.com Jonathan

      I will check them out.

  • Pingback: Running Visual Studio 2010 Generated Deployment Scripts in SSMS

  • http://pulse.yahoo.com/_OLXRTFO4KOVDG7EEX6NJUOOFZ4 fx

    Hy there. I would like to know if there is any way of making a executable (such as an updater of some sort) that if u run at a particular database it will make the deployment script and execute it. Is that possible ?

    • http://www.jonathanagardner.com Jonathan Gardner

      You should be able to do it by creating a setup project. I have never done it that way but it should be possible. Sorry I don’t have much more for you.

  • http://www.jonathanagardner.com Jonathan Gardner

    Peter, The series is not dead but has been put on hold while I work on getting our corporate blog online, http://blog.insource.com. Now on to your situation. It sounds to me like you have two projects 1 for the OLTP and one for the reporting. If your reporting branch will contain the information from your OLTP database you would start with that database. You would create two branches one for the OLTP and one for reporting. References is a possibility if you did not want to maintain it as one large project. I don’t know if I would mess with partial projects, as you can see, they can get complex very quickly.

    Check out this video on Branching and Merging http://bit.ly/c153gu. I am sure you have already seen this as well but here is the BOL link for branching and merging as well http://bit.ly/9qtNKw.

    Let me know if any of this helps. My future posts will probably show up on our corporate blog http://blog.insource.com with a link from this site.

Previous post:

Next post: