我右键单击 CREATE TABLE 脚本中的列名并选择 Refactor | 改名。它重命名了该列,并且预期的条目出现在重构日志 XML 文件中。
但是,当我从项目到数据库运行模式比较然后生成脚本时,该脚本没有提及重构,并且想要删除现有列名并使用新名称添加它。
我在这个数据库中没有 _RefactorLog 表。部署脚本不会尝试创建一个。就好像它完全忽略了重构日志 XML 文件的存在。
XML 文件确实以预期的 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>
我在部署脚本中看到了这一点:
/*
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.
*/
我怎样才能得到这个工作?
注意:项目文件(和所有其他文件)在运行模式比较之前已保存。重构日志文件是预先存在的,大约一年前我上次使用重构重命名功能时有大约六个条目,除了当前更改集中的两个新条目。并不是说这个功能对我没用过,而是它以前可以用的时候就不再有效了。
我正在使用带有 SSDT 11.1.31009.1 的 VS 2012 Premium 11.0.60610.01 Update 3。
谢谢,马克