问题
I'm having a seemingly identical problem to what is described here: SSDT Refactor Rename is ignored by the Schema Comparison script generation. Essentially, the refactor component of SQL Server Data Tools is not working on schema comparison/update. Instead of renaming a table, for instance, the table with the old name is dropped and the table with the new name is created. Unfortunately, I do not see an accepted answer to that question. I found a similar question, which seems to be have been asked by the same person on MSDN; see: Refactor Rename is ignored by the Schema Comparison script generation. Again, it doesn't look like an acceptable answer was proposed. I would really like to figure out how to get this feature to work. Does anyone have an idea?
回答1:
Figured out the cause of this problem. I noticed that when doing a schema compare against my SQL Data Tools project and a different (yet essentially identical) database, the refactor component was in fact considered. I took a look at the generated SQLCMD script, and at the bottom saw lots of entries that looked like this...
IF NOT EXISTS (SELECT OperationKey FROM [dbo].[__RefactorLog] WHERE OperationKey = 'ce3d4c93-c1c4-4967-9cd5-0048d1e7d22f')
INSERT INTO [dbo].[__RefactorLog] (OperationKey) values ('ce3d4c93-c1c4-4967-9cd5-0048d1e7d22f')
I took a look at the database on which I was having problems and sure enough, under System Tables in SS MS, I found dbo.__RefactorLog. After truncating this table, the schema comparison again showed the proper refactoring.
来源:https://stackoverflow.com/questions/27845533/sql-server-data-tools-ignores-refactor-on-schema-compare