SQL Server Data Tools Ignores Refactor on Schema Compare

帅比萌擦擦* 提交于 2020-01-15 05:57:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!