Refactoring Database Objects in a Team Environment

With Microsoft Visual Studio Team Edition for Database Professionals, you manage change by putting the offline representation of the database schema, which is called the database project, under a version-control system. You or a member of your team can change the database project, but those changes must then be built and deployed to a live database. In this situation, up to three representations of the database can exist:

  • The database server, which contains the live database and the data.

  • The database project, which is the offline representation of the database schema.

  • The version-control repository, which tracks all changes that any member of the team makes to the database project.

For more information, see An Overview of Database Creation and Deployment in a Team Environment.

Rename Refactoring in a Team Environment

If you use refactoring to rename a schema object, other objects that reference the renamed object are automatically updated with the new name. For example, you can rename a column in a table, and any stored procedures that reference that column are automatically updated with the new name. For more information, see Overview of Rename Refactoring.

Before you can rename a schema object, you must have checked out from source control the files for other objects that are updated. If you do not check out these files before you try the renaming operation, you can try to check them out. If you have set your source control option to automatically check out files, the check-out attempt is made silently. Otherwise, you are prompted to check out the files.

The rename operation does not succeed in the following situations:

  • If someone else has locked any of the files, an error message appears, and the rename operation is canceled. You must wait until the files are unlocked before you try the rename operation again.

  • If the versions that you check out are newer than the version in your project, an error message appears, and the rename operation is canceled. You can try the rename operation again immediately.

  • If you are prompted to check out the files and you click Cancel, the rename operation is canceled.

    Note

    When you rename a database object, the .sql file that is associated with that object is not renamed. You can rename the file manually in Solution Explorer.

See Also

Other Resources

Refactoring Databases
Renaming Database Objects
Creating and Updating Version-controlled Database Schemas