

- #Compare databases using dbschema how to#
- #Compare databases using dbschema update#
- #Compare databases using dbschema series#
To complete our ultimate goal of database versioning awesomeness, we are going to use the following commands to “Make it happen” (You need to replace the items in CAPS with your server’s details):

Once we have a dbschema file for our local (source) database, we will then create one for our staging or production (destination) database, and after that we will compare the two schema files and get the Visual Studio Database command-line tool to generate a change script that can be run on our destination database server to bring it up to speed with our development database. This can reside anywhere within connection reach from you build server, it can even reside ON your build server, if you wanted to setup a local SQL express database on your build server to simply for database comparison. In order to generate a database change script for deployment to our staging or production database we will first create a dbschema file that represents our local development database.
#Compare databases using dbschema update#
Using the Visual Studio Database command-line tool VSTSDB.exe we’ll take the following approach to the automated generation of our database schema update SQL scripts. ExtensionArguments: (short form Read response file for more options Our Automated Approach DatabaseSchemaProvider: (short form /dsp) DeploymentScriptFile: (short form /script) TargetModelFile: (short form /targetmodel) DatabaseSchemaProvider: (short form Read response file for more options The documentation for this command-line tool can be found here.Īsk anyone who is into Continuous Integration, and they’ll tell you that command-line tools are like pirate’s treasure when it comes to build-automation – this case is no different.Ī quick take a look at the overloads that this little nugget of Continuous Delivery gold delivers: VsDbCmd: Command-line tool for deploying Visual Studio database projects.Ĭopyright (c) Microsoft Corporation. % ProgramFiles( x86)%\Microsoft Visual Studio 10.0\VSTSDB\Deploy The command-line tool is called vsdbcmd.exe and sits inside the Visual Studio VSTSDB folder under the Visual Studio 2010 root: I say this, because they included a command-line versions of the tool that does database schema comparisons, *.dbschema file generation and *.dbschema file deployment. The developers working on the Visual Studio team were very kind to the fans of Continuous Integration when they built the Database tools that come with Visual Studio. Command-line versions of the Visual Studio tools It stores the entire state of the database at the time of generation, and is a good way to version a database for tagging your database’s schema as part of your automated build, potentially for comparison, deployment or simply piece of mind – using these files to deploy directly to a database server is something i will show you in a later post. So what does a *.dbschema file’s contents look like? Ī *.dbschema file is quite powerful in the world of Visual Studio’s Database tools. This file stores everything that defines a database’s structure so that it can be deployed, used in a database schema comparison or imported into a Visual Studio database project. Visual Studio’s database tools store a database’s schema in a file that has a file extension *.dbschema.
#Compare databases using dbschema how to#
The examples shown in this post can really be used with any build server – i will show you the command-line tools to run, and how to enter them into TeamCity, but at the end of the day the principles shown in this post can be used on any build server, in a build script like MSBUILD or NANT or simply from the command-line ‘old-school style’.
#Compare databases using dbschema series#
Last week i posted about “ Visual Studio’s Best Kept Secret – Compare & Update Database Schemas Right From Within the IDE” and this post is part two of this series on Visual Studio Premium’s Database Schema Comparison features. I will show you how to do this easily and also automatically deploy the changes to your destination server with the awesomeness of TeamCity. If you have a Visual Studio Premium installed on your build server, generating schema update scripts is easy to achieve with the built-in database tools that the IDE contains.

When updating a project’s Database Schema as part of your deployment strategy, you want to automate as much of the process as possible to avoid human errors.
