SSDT 重构重命名被架构比较脚本生成忽略 [英] SSDT Refactor Rename is ignored by the Schema Comparison script generation

查看:26
本文介绍了SSDT 重构重命名被架构比较脚本生成忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 CREATE TABLE 脚本中右键单击列名并选择了重构 |改名.它重命名了该列,并且预期的条目出现在 refactorlog XML 文件中.

I right-clicked on a column name in a CREATE TABLE script and selected Refactor | Rename. It renamed the column and the expected entry appears in the refactorlog XML file.

但是,当我运行从我的项目到我的数据库的模式比较然后生成脚本时,该脚本没有提及重构,并且想要删除现有的列名并使用新名称添加它.

However, when I run a Schema Comparison from my project to my database and then generate the script, the script contains no mention of a refactoring and wants to drop the existing column name and add it with the new name.

我在这个数据库中没有 _RefactorLog 表.部署脚本不会尝试创建一个.就好像它完全忽略了 refactorlog XML 文件的存在.

I have no _RefactorLog table in this database. The deployment script does not attempt to create one. It's like it is completely ignoring the presence of the refactorlog XML file.

XML 文件确实以预期的 xmlns 开头:

The XML file does start with the expected xmlns:

<?xml version="1.0" encoding="utf-8"?>
<Operations Version="1.0" xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
   <Operation Name="Rename Refactor" Key="4c6a080c-0626-4824-9b59-8ecfd491319a" ChangeDateTime="11/18/2013 19:03:13">
    <Property Name="ElementName" Value="[dbo].[Report].[Name]" />
    <Property Name="ElementType" Value="SqlSimpleColumn" />
    <Property Name="ParentElementName" Value="[dbo].[Report]" />
    <Property Name="ParentElementType" Value="SqlTable" />
    <Property Name="NewName" Value="[DisplayName]" />
  </Operation>
</Operations>

我在部署脚本中看到了这一点:

I see this in the deployment script:

/*
The column [dbo].[Report].[Name] is being dropped, data loss could occur.

The column [dbo].[Report].[DisplayName] on table [dbo].[Report] must be added,  
but the column has no default value and does not allow NULL values. If the table 
contains data, the ALTER script will not work. To avoid this issue you must 
either: add a default value to the column, mark it as allowing NULL values, or 
enable the generation of smart-defaults as a deployment option.
*/

我怎样才能让它工作?

注意:在运行架构比较之前保存了项目文件(和所有其他文件).重构日志文件是预先存在的,大约一年前我上次使用重构重命名功能时有大约六个条目,此外还有当前更改集中的两个新条目.并不是这个功能对我来说从来没有用过,而是它以前工作的时候不再工作了.

Note: The project file (and all other files) was saved before running the Schema Comparison. The refactorlog file was pre-existing, with about a half-dozen entries from the last time I used the refactor rename feature about a year ago, in addition to the two entries that are new from the current set of changes. It's not that this feature has never worked for me, it's that it no longer works when it used to work.

我使用 VS 2012 Premium 11.0.60610.01 Update 3 和 SSDT 11.1.31009.1.

I am using VS 2012 Premium 11.0.60610.01 Update 3 with SSDT 11.1.31009.1.

谢谢,标记

推荐答案

我不确定这是否是您需要的答案,马克,但我对这个问题的解决方案描述如下:SQL Server Data Tools 在架构比较时忽略重构.本质上,SQL Data Tools 在数据库中维护元数据以确保重构只执行一次.我很想知道这是否是您问题的根源.如果没有,您有没有找到正确的解决方案?

I am not sure if this is the answer you need, Mark, but my solution to this problem is described here: SQL Server Data Tools Ignores Refactor on Schema Compare. Essentially, SQL Data Tools maintains metadata in the database to ensure that a refactor is only performed once. I'd be interested to know if this was the source of your problem. If not, did you ever find a correct solution?

这篇关于SSDT 重构重命名被架构比较脚本生成忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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