Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Connected database development in your Solution Explorer

th

Last update: 19 Apr 2012

Introduction
SQL Connect allows you to edit a database in Visual Studio and easily share changes using your current source control solution. SQL Connect makes a project of CREATE scripts that can be included in your solution together with associated application code. This allows you to modify the database or edit the project files while synchronizing them with a single click. The project can then be shared using your existing source control solution. The SQL Connect project is compatible with Red Gate SQL Source Control and SQL Compare so your team can work on the database in either Visual Studio or SQL server Management Studio (SSMS) and deploy from Source Control to test and production environments.

Installation
SQL Connect is an add-in for Visual Studio 2010 so this must be installed first. SQL Connect also relies on an existing source control plug-in to manage files representing the database. We have tested so far with TFS and AnkhSVN. Double-clicking the downloaded EXE file starts the SQL Connect Installer. This contains a trial for SQL Prompt which provides code completion and other productivity features in both Visual Studio and SQL Server Management Studio

Getting Started
After installation, SQL Connect displays a new window in Visual Studio offering two alternatives for getting started.

The first option allows you to create a new project from the Visual Studio Open Project dialog box while the second allows you to work with an existing project made using Red Gate SQL Source Control in SSMS. For more information on the second option, please see the instructions here.

When you select Red Gate Database Project, SQL Connect invites you to specify the database that will be linked to the new project.

SQL Connect builds a project of CREATE scripts representing the database and adds it to your Visual Studio solution.

A panel is displayed explaining that you can directly modify the database or edit the CREATE scripts in the project, synchronizing them with a single-click. Unlike SQL Source Control, SQL Connect does not manage source control of the project; it lets your existing Source Control plug-in manage this together with other files in your solution. The solution explorer shows all the objects in the database in a similar structure to SSMS.

Right-clicking an object shows two ways of interacting with the database: you can open a query window or table designer to directly modify the database or you can edit the offline CREATE scripts in the project. The title bar of the window shows whether you are working on the connected database or the project file.

You can use the buttons on the windows to execute queries or save changes. After you make a change to the database or the project, SQL Connect warns they are out of sync with a bar in the edit window and an amber or blue indicator on the sync panel (amber for a database change and blue for a project change).

You can start the synchronization process using the buttons on the edit window or the sync panel or the context menu item in the solution explorer or the item in the main Tools menu. The sync panel then shows a progress bar followed by a report of the number of objects changed. More detailed information is shown in the output window. If conflicting changes are detected during synchronisation, a dialog box pops up allowing you to select either the project or database version of the conflicting object. This approach enables you to work by directly modifying the database or editing the project files. Once changes have been synchronized, you can share them with colleagues using your existing source control solution.

We would love to hear how well this works for you and what changes you would like us to make going forward. Here is a link to our feedback forum; there are similar links in the tool.

Appendix: Working with an existing Red Gate SQL Source Control project
This option allows you to share a source control repository created by Red Gate SQL Source control in SQL Server Management Studio. The Setup tab in SSMS shows the location of the repository.

The first step is to check out the SQL Source Control project using your preferred Source Control tool. For example, TFS provides a Source Control Explorer within Visual Studio enabling you to locate the repository made by SQL Source Control, map it to your Workspace and check out the project to your development environment. Tortoise SVN provides a standalone repository browser that you can use to locate and check out the desired project.

Note that if you want to make atomic commits of database changes and application code within the same solution, it is preferable to check out the database project into a sub-directory within the solution folder. Once you have a local folder containing your database project, click on the Import option on the SQL Connect welcome panel in Visual Studio.

This displays a dialog box into which you can enter the location of your checked out SQL Source Control project.

Once you have selected the directory, SQL Connect adds the project to your solution in Visual studio. This must be then connected with your local development database so changes to the project and database can be easily synchronized. Right-clicking on the Red Gate project will show the properties and let you select the database.

Once your development database is connected to the project, you can interact directly with the database or with the CREATE scripts in the project. The SQL connect panel is used to keep these synchronized so you can easily manage your work with the existing Visual Studio Source Control plug-in.

You might also like