Here is another interesting use case for rename refactoring – coalescing two or more objects. What do I mean by that?
Well, this one is slightly different from what would traditionally be considered rename refactoring. It smells more like a semi-automated Merge Tables database refactoring.
Let’s say the scenario here is that you have a [dbo].[Contacts] table and a [dbo].[ContactPhotos] table. Both tables are keyed on ContactID. You may realize that you always end up joining these tables and thus wish to merge the ContactPhotos table with the Contacts table.
Let’s say the table definitions for these objects are as follows:
CREATE TABLE [dbo].[Contacts]
ContactID int NOT NULL,
FirstName varchar(100) NOT NULL,
MiddleName varchar(100) NULL,
LastName varchar(100) NOT NULL,
BirthDate datetime NULL,
SSN varchar(50) NOT NULL,
CREATE TABLE [dbo].[ContactPhotos]
ContactPhoto image NULL
To simplify this task, you can use rename refactoring to get you most of the way. Just follow these steps:
In upcoming CTP6 you will be able to leverage this feature exactly as described above. So check it out!