2017-05-05 82 views
1

我試圖改變一個表通過實體框架的核心遷移的主鍵:當我嘗試更新,我得到以下錯誤信息數據庫更改使用實體框架的核心遷移主鍵

protected override void Up(MigrationBuilder migrationBuilder) 
{ 
     migrationBuilder.DropPrimaryKey(
      name: "PK_Permissions", 
      table: "Permissions"); 
} 

To change the IDENTITY property of a column, the column needs to be dropped and recreated. 

如何更新數據庫?

+2

我不認爲遷移支持這種特殊情況。你必須自己編程。 –

+1

如果您先丟棄該列,該怎麼辦? migrationBuilder.DropColumn( name:「Id」, schema:「dbo」, table:「Permissions」); migrationBuilder.DropPrimaryKey( name:「PK_Permissions」, table:「Permissions」); – alessalessio

回答