By: Armando Prato
Overview
Databases are made to be refactored. Objects are always being modified as a database evolves. How can changes be accomplished?
Explanation
Refactoring existing database objects is just as easy as adding new objects. Let's refactor the Team table'sCity column to CityName.
Within the Solution Explorer, double click on the Team.sql file. This will present the dual Design/T-SQL panes. Within the T-SQL pane, right click on the City column and choose Refactor and Rename:
You will be presented with the Rename dialog. Change City to CityName and click OK
Note the checked Preview changes check box. This allows you to examine the changes before they're applied.
Clicking Apply ripples the change of City to CityName throughout our project including to the post-deployment script we created for initial data insert. As a by product of the refactor, a Futbol.refactorlog file is created inside the Solution Explorer.
Now let's publish these changes. Remember the FutBol.publish.xml file we saved previously? We can now leverage it. In the Solution Explorer, double clicking on this file presents the Publish Database with the target instance pre-filled. If we had any advanced options modified from their defaults, they'd be included automatically as well.
Just click Publish and examine the Output pane:
Examining our SQL Server database, we can see the change from City to CityName has been applied:
Last Update: 7/22/2014