SQL Server source control from Visual StudioPublished 30 April 2012 1:16 pm
Developers have long since had to context switch between two IDEs, Visual Studio for application code development and SQL Server Management Studio for database development. While this is accepted, especially given the richness of the database development feature set in SSMS, loading a separate tool can seem a little overkill.
This is where SQL Connect comes in. This is an add-in to Visual Studio that provides a connected development experience for the SQL Server developer. Connected database development involves modifying a development sandbox database, as opposed to offline development, where SQL text files are modified independently of the database. One of the main complaints of Data Dude (VS DBPro) is that it enforces the offline approach. This gripe is what SQL Connect addresses.
If you don’t already use SQL Source Control, you can get up and running with SQL Connect by adding a new project to your Visual Studio solution as follows:
Then choose your existing development database and you’re ready to go.
If you already use SQL Source Control, you will need to link SQL Connect to your existing database scripts folder repository, so SQL Connect and SQL Source Control can be used collaboratively (note that SQL Source Control v.184.108.40.206 or later is required).
Locate the repository (this can be found in the Setup tab in SQL Source Control).
.and create a working folder for it (here I’m using TortoiseSVN).
Back in Visual Studio, locate the SQL Connect panel (in the View menu if it hasn’t auto loaded) and select Import SQL Source Control project
Locate your working folder and click Import.
This creates a Red Gate database project under your solution:
From here you can modify your development database, and manage your changes in source control. To associate your development database with the project, right click on the project node, select Properties, set the database and Save.
Now you’re ready to make some changes. Locate the object you’d like to modify in the Solution Explorer, and double click it to invoke a query window or table designer. You also have the option to edit the creation SQL directly using Edit SQL File in Project.
Keeping the development database and Visual Studio project in sync is as easy as clicking on a button.
One you’ve made your change, you can use whichever mechanism you choose to commit to source control. Here I’m using the free open-source AnkhSVN to integrate Subversion with Visual Studio.
Maintaining your database in a Visual Studio solution means that you can commit database changes and application code changes in the same changeset. This is desirable if you have continuous integration set up as you want to ensure that all files related to a change are committed atomically, so you avoid an interim “broken build”.
More discussion on SQL Connect and its benefits can be found in the following article on Simple Talk: No More Disconnected SQL Development in Visual Studio
The SQL Connect project team is currently assessing the backlog for the next development effort, and they’d appreciate your feature suggestions, as well as your votes on their suggestions site:
A 28-day free trial of SQL Connect is available from the Red Gate website.