Move along… No dacpac to see here!!!
So before I will show an alternative way to achieve application lifecycle management let’s get a shortlist of what tools you need to even begin to use the Data-tier Applications. You must have:
- SQL Server 2008 R2
- Visual Studio 2010 Ultimate or Premium (Professional has limited power here)
So, by just using SQL Server 2008 R2 and Visual Studio 2010 Ultimate can I achieve the same as this awesome thing called a DACPAC? Good news, you can and I will show you how.
I’ve created the same database as in the first post. Now I will fire up VS2010 and choose a SQL Server 2008 Database project template. It looks the same as the Dacpac template but there are some important differences which we will notice later. First off you will have to import the schema either by using a script or connecting to the database and import it from there.
First off is to add a CustomerAddress column. This is the same as with the Dacpac. When that’s done make life easy for the sake of the demo and right click the project and choose Properties. Select the Deploy tab and put in the right connection string and live database name. This is just for the sake of not typing all the stuff in the cmdbox. But if you are in a life environment get some guidance here.
Then start off a VS2010 command line to be able to use VSDBCMD which is a command line tool to deploy databases. And if you were thinking that a DBA does not have VS2010 check out this page to see how that’s dealt with. Navigate to the debug folder of your project where all the output will be created. Notice the files in the screenshot below. Some of theme you will see in the Data-tier as well. Now run VSDBCMD /a:Deploy /dd+ /manifest:[Manifestfile]. This will deploy your database.
Now that was easy, nobody was hurt and no DACPACs were killed using this procedure. So let’s see how VS2010 and this SQL Server 2008 Project does scenario 2 where we add a column with a default constraint.
- Add the OrderDate column as DATE data type with NOT NULL to the .sql script for the Orders table. Notice how this is trimmed down from the Data-tier version. There are no constraints here. So where are they? Well, where they belong, at the constraints folder. Nice to see everything nice and tidy.
- So navigate to the Constraint folder, right click and choose Add Item. From the next screen choose Default Constraint. Yes, it’s there. It was not with the Data-tier Application, but it is supported on this SQL Server 2008 Project.
- So, add the constraint and click Build followed by Deploy.
- Fire up the command line again and run the same command as before and presto. Database updated.
And you might want to take notice of the next points as well:
- No database was copied, dropped or created.
- No data was copied unless absolutely necessary.
- You can specify file groups and files within the database project if you like.
What’s the catch? Nothing, this is all available in Visual Studio Premium and Ultimate as with the Data-tier applications. But wait,it gets better. This stuff works on older SQL versions as well. And it can do more,like Schema compare and data compare. It also implements with your build process and can be included in web deployment.
So we have a great tool (which we already had as Add-in for Visual Studio 2008) that does amazing things with a database. This tool has been around for somewhat two years now and is getting better with every release. And here comes SQL 2008 R2 to the rescue with the Data-tier application. It does less, does it worse and just creates a new database in essence. In my opinion it has the words EPIC FAIL written all over it. Maybe it’s time Microsoft took a good look inside its own organization and starts normalizing. There is some redundant data there (remember LINQ2SQL and the Entity Framework).
The way the Data-tier application is implemented at this point I will not use it. If in a future release it will be extended and there will be more (live) migration possibilities with Multi Server Management it will be a whole different story.




