SQL Server Data Tools 在架构比较时忽略重构 [英] SQL Server Data Tools Ignores Refactor on Schema Compare

本文介绍了SQL Server Data Tools 在架构比较时忽略重构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与此处描述的问题看似相同的问题:SSDT 重构重命名被架构比较脚本生成忽略.本质上,SQL Server Data Tools 的重构组件不适用于架构比较/更新.例如,不是重命名表,而是删除具有旧名称的表并创建具有新名称的表.不幸的是,我没有看到该问题的公认答案.我发现了一个类似的问题,这似乎是同一个人在 MSDN 上提出的;请参阅:架构比较脚本生成忽略重构重命名.同样,它看起来不像是提出了可接受的答案.我真的很想弄清楚如何让这个功能发挥作用.有人有想法吗?

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?

推荐答案

找出这个问题的原因.我注意到,当对我的 SQL Data Tools 项目和不同(但基本相同)的数据库进行模式比较时,实际上考虑了重构组件.我查看了生成的 SQLCMD 脚本,在底部看到了很多看起来像这样的条目......<代码>如果不存在(SELECT OperationKey FROM [dbo].[__RefactorLog] WHERE OperationKey = 'ce3d4c93-c1c4-4967-9cd5-0048d1e7d22f')INSERT INTO [dbo].[__RefactorLog] (OperationKey) 值 ('ce3d4c93-c1c4-4967-9cd5-0048d1e7d22f')

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')

我查看了我遇到问题的数据库,果然,在 SS MS 中的系统表下,我找到了 dbo.__RefactorLog.截断这张表后,模式比较再次显示了正确的重构.

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.

这篇关于SQL Server Data Tools 在架构比较时忽略重构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆