locked
Table with computed column is altered each deploy

    问题

  • Hi,

    I have a table with a computed column in my database project:

    create table MyTable (
      NameCode char(7),
      AddressCode char(3),
      Name nvarchar(80),
      FullAddress nvarchar(max),
      FullCode char(10),
      constraint PK_MyTable
        primary key (NameCode, AddressCode),
      constraint UQ_MyTable
        unique (FullCode)
    )

    Each time when I deploy the project, the Unique Key is dropped, the column FullCode is dropped, the column FullCode is added back again and the Unique Key is created again.

    Is this a bug, or implemented by design?

    Adri


    Programmers do it Bit by Bit

    2012年3月1日 11:38

答案

  • Hello Adri,

    I am sorry that I can't reproduce the same issue as you, with the script you offered above, I just have the Unique key and the FullCode column created for the first time when I deploy the database project. In addition, what about other database objects? Will they be deleted and recreated again as well? If so, please make sure you don't select the "Always re-create database" option in the Database.sqldeployment file.

    And if the above workaround does not resolve your issue, I think maybe there are some other database objects in the database project cause you the Unique key and the column re-created. It is better if you can provide me the sample project which can reproduce your issue. I would like to take a look at of it for you.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月2日 9:35
    版主