2017-05-05 126 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

回答