Cant remove identity attribute from PK

前端 未结 2 1546
故里飘歌
故里飘歌 2020-12-11 22:12

I need to change the data type of the primary key on one of my tables to string from int (I didn\'t say I WANT to...). The migration generates this bit of code:

<         


        
2条回答
  •  醉话见心
    2020-12-11 22:31

    Removing an identity specification from a column can only be done by re-creating the table. Look at the ALTER TABLE - ALTER COLUMN statement: there is no syntax to change (add or remove) an identity specification.

    So I'm afraid you'll have to do this manually and make a fresh start for subsequent migrations.

    BTW Sql Server Management Studio won't help you doing this. You may want to use Toad for Sql Server. It creates a full table rebuild script when you remove an identity specification.

提交回复
热议问题