SSDT Refactor Rename is ignored by the Schema Comparison script generation

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.

  • How do you set permissions on a schema that has objects accessing other schemas?
  • Check if string doesn't contain another string
  • SQL Server 2008 R2: Restore a single filegroup
  • How do I set the default database in Sql Server from code?
  • T-SQL stored procedure, use variable as table reference in query
  • SQL sum by year report, looking for an elegant solution
  • 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.

    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.
    */
    

    How can I get this working?

    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.

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

    Thanks,
    Mark

  • Visual Studio 2015 Schema compare not displaying changes
  • How to setup schema compare file so that it always ignores a specific db schema?
  • SQL Schema compare - column level actions
  • SSDT - Schema compare drops old sprocs, publish does not
  • SQL Server / SQL Azure Schema Compare
  • Visual Studio SQL Server Schema Compare by Schema Name
  • 2 Solutions collect form web for “SSDT Refactor Rename is ignored by the Schema Comparison script generation”

    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?

    I just ran into this same issue, none of the suggestions worked out. It turns out that – in my case, at least – the Build Action property for the refactor log file was set to “None” – it should be set to “RefactorLog”. Once I changed this setting and re-generated the script, all the associated entries in the log were addressed in the generated scripts.

    Hope this helps someone.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.