# Sunday, August 10, 2008

Visual Studio Team System 2008 Database Edition is a mouthful to say, so a lot of people affectionately call it “Data Dude”.

Data Dude provides a set of tools integrated into Visual Studio that assist developers in managing and deploying SQL Server database objects.

There are four tools in this product that I have found particularly useful: the Database Project; the Schema Compare tool; the Data Compare Tool; and Database Unit Tests.

A Database Project is a Visual Studio project just as a class library or ASP.Net web project is.  However, instead of holding .Net source code, a Database Project holds the source code for database objects, such as tables, views and stored procedures.  This code is typically written in SQL Data Definition Language (DDL).  Storing this code in a Database Project makes it easier to check it into a source code repository such as Team Foundation Server (TFS); and simplifies the process of migrating database objects to other environments.

The Schema Compare tool is most useful when comparing a database with a Visual Studio Database Project.  Developers can use this tool after adding, modifying or deleting objects from a database in order to propagate those changes to a Database Project.  Later, a Database Administrator (DBA) can compare the Database Project to a different database to see what objects have been added, dropped or modified since the last compare.  The DBA can then deploy those changes to the other database.  This is useful for migrating data objects from one environment to another, for example when moving code changes from a Development database to a QA or Production database.

The Data Compare is another tool for migrating from one database environment to the next.  This tool facilitates the migration of records in a given table from one database to another.  The table in both the source and destination database must have the same structure.  I use this when I want to seed values into lookup tables, such as a list of states or a list of valid customer types that are stored in database tables.

Unit tests have increased in popularity the last few years as developers have come to realize their importance in maintaining robust, error-free code.  But unit testing stored procedures is still relatively rare, even though code in stored procedures is no less important than code in .Net assemblies.  Data Dude provides the ability to write unit tests for stored procedures using the same testing framework (MS Test) you used for unit tests of .Net code.  The tests work the same as your other unit tests – you write code and assert what you expect to be true.  Each test passes only if all its assertions are true at runtime.  The only difference is that your code is written in T-SQL, instead of C# or Visual Basic.Net. 

There are some limitations.  In order to use Data Dude, you must have either SQL Server 2008 or SQL Express installed locally on your development machine and you (the logged-in user) must have "Create Database" rights on that local installation.  To my knowledge, Data Dude only works with SQL Server 2000 and 2005 databases.  Plans to integrate with SQL Server 2008 have been announced but I don't know Microsoft's plans for other database engines.   I also occasionally find myself wishing Data Dude could accomplish its tasks more easily or in a more automated fashion.  I wish, for example, I could specify that I always want to ignore database users in a database and always want to migrate everything else when using the Schema Compare tool.  But overall, the tools in this product have increased my productivity significantly.  Nearly every application I write has a database element to it and anything that can help me with database development, management and deployment improves the quality of my applications.

.Net | SQL Server | VSTS
Monday, August 11, 2008 3:11:24 PM (GMT Daylight Time, UTC+01:00)
"Datadude" was directly responsible for putting corrupted code into production on one of our major projects. There is no way that I would recommend it until all the kinks are worked out. As of a few months ago, I would not even classify it as a beta version.
blindman
Monday, August 11, 2008 3:37:07 PM (GMT Daylight Time, UTC+01:00)
We used DataDude on a project (the same one that Bruce "blindman" was working on). I like the concept of putting your database in source control.

What I haven't figured out yet is once you put out a release, how do you update your database for the next release? You can't just have DataDude generate a change script because there will probably have to be manual SQL written to update data, do things in a certain order, etc. I don't know how you can do this safely without alter scripts.
Thursday, August 14, 2008 6:36:33 PM (GMT Daylight Time, UTC+01:00)
Jon,

Data Dude is smart enough to do things in the correct order to enforce referential integrity but sometimes you need updates to occur in a given order beyond ref integrity.

For those cases, you can export your database schema updates to a SQL script and then modify that script by hand before runing it in an SQL query window. This was the process we took on my last project when we wanted to change the name of linked servers in views (which Data Dude doesn't handle well).

The schema compare / export process is described at http://www.davidgiard.com/2008/08/13/DataDudeTutorial3UsingSchemaCompareToolToDeployDatabaseChanges.aspx

Friday, August 22, 2008 7:43:11 PM (GMT Daylight Time, UTC+01:00)
Is DataDude included with the Visual Studio 2008 Professional edition?
Comments are closed.