开发者

SQL Server schema comparison - leaves behind obsolete files on synchronization

开发者 https://www.devze.com 2022-12-29 23:52 出处:网络
Directly related to visual studio 2010 database开发者_JAVA技巧 project, is there a visual way? I have a problem synchronizing between database project and a database in Visual Studio.

Directly related to visual studio 2010 database开发者_JAVA技巧 project, is there a visual way?

I have a problem synchronizing between database project and a database in Visual Studio.

Usually I synchronize FROM database TO database project (using the Visual Studio > data > scheme compare > new schema comparison).

The synchronization works, BUT when I for example corrected the spelling of a key in the database and synchronized it - the file with the WRONG spelling of a key remains (albeit is commented out inside). the new one is correctly added.

This file happens to be in:

[project name]/Scheme Objects/Schemas/dbo/Tables/Keys

But for sure there are others elsewhere.

how to automatically remove such obsolete files when synchronizing?

thnx


You could write a small console application (or a script) that looks at all files in your project and remove the ones that contain only commented sql statements.

There is one thing to consider though: If you re-name an object you might want to tell your source control system that you re-named the object i.e. you would not just delete the old file. This way you would preserve the history of the object (I think with Git this would not be an issue but it is for others).

Usually I pull the changes from the database into my project very frequently and thus I only have couple of files that change. This way it is not too hard to manually delete obsolete files or make my source control system believe that I renamed a file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号