Pages

Friday 14 November 2008

Friday - DB Deployment and Unit-Testing with DBPro

TLA03-HOL - Introduction to Visual Studio Team System 2008 Database Edition I took this lab as a follow-up to Brian Randell's talk on Tuesday. This is by far the most useful tool I learned about at this TechEd. You start by creating an empty database project.
  • Then you import the schema from an existing database. VSTS automatically creates a folder struture for schema objects in the solution folder. Each db object has got its own script therefore you can commit them all into CVS if you need to (you don't have to use Foundation Server).
  • To add an object, right-click Add Table in the Schema View. This generates a script skeleton that you edit as you see fit (add columns, add options, etc...). Save the file and the Schema View is updated automatically. Change an object in the Schema View and the script is updated automatically.
Schema compare That's where it gets interesting:
  • Choose a target database to compare the offline schema to the target schema.
  • A view appears that shows all changed, new or missing objects.
  • Select one of the changed object in the lists and view the difference (new column, changed line in sproc, etc..)
  • You can also preview the DDL script that VSTS is about to generate
  • You can enable/disable individual differences from the list if you don't want them to be part of the script or force some to be in the scripts if you really want them to be there.
  • Export the DDL script to a .sql file then edit if you need to tweak it before testing it against a pre-prod database.
So the tool is nice because it does the dirty work for you, leaves you a high degree of control and makes the schema differences absolutely crystal clear. Database unit-testing
  • You can create a unit-test for a sproc.
  • VSTS automatically creates a test class that calls the sproc that contains the unit test. All you have to do is write the T-SQL for the sproc that does the unit-test. DB Sprocs tests are therefore perfectly integrated to all other tests.
  • You can attach a Pre-Test and Post-Test to a sproc test in order to put the db into an known state.

1 comment:

Anonymous said...

Your Introduction to Visual Studio Team System 2008 Database Edition...well I must say you published a post which is very useful to me..I mean i just love this sort of explanations that guide you all the way...and that leave no room for
misunderstanding
of anything written....I mean you said click this and this...click right--Save As..well I am sure you know what I a mean....Thx again..and would love to see more posts of the sort!