Changing Primary Key using Entity Framework Core Migrations

ef-migrations entity-framework-core primary-key

Question

I am trying to Change the Primary key of a table via Entity Framework Core Migrations:

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

When I try to update the database I get the following error message:

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

How can I update the database?

1
5
5/5/2017 7:11:43 AM

Accepted Answer

I have found a solution: This seems to be a bug in EF Core 1.1

I changed the Migration file.

More Information about this can be found here: https://thisworksonmymachine.com/2017/02/13/ef-core-the-setup-part-4/

3
5/5/2017 9:11:07 AM

Popular Answer

On attempting to get IdentityServer4 EF migrations (SQLServer) I had this same problem. Updating Microsoft.EntityFrameworkCore to v2.1.3 and Microsoft.EntityFrameworkCore.Tools to v2.1.3 seemed to fix the issue.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow