Tuesday, August 14, 2012

Renaming Objects in Visual Studio Database Projects

Just so you know, if you want to rename a table, column, etc. in a Visual Studio database project, don’t just change the object name in the definition file.  Instead, right click on the object and choose Refactor→Rename. This will (1) rename it everywhere else it is used (good!), and (2) make sure the deployment script that is eventually generated knows that the table or column was renamed so that it will rename it instead of dropping and recreating it (double plus extra good!).

I just tried this: changing the datatype of a column I renamed on a table I renamed; the resulting deployment script renamed the table, then renamed the column, and then altered the column to the new datatype. Just what I wanted!

No comments:

Post a Comment

There was an error in this gadget