Jim Evans
Jim Evans

Reputation: 6525

.Net 5 EF Core change data type of key in table

I am working on a new application in .Net 5 using EF Core. After creating some entity classes and doing the first few migrations I discovered that I wanted to change the data type of column and make it the key in one of the tables. I was able to do that without issue and the app works just fine with that change - but now if I try to change anything else in that table like add a new column and do a migration I get the following error: "To change the IDENTITY property of a column, the column needs to be dropped and recreated." I have tried even dropping the entire table - but nothing seems to work.

Upvotes: 0

Views: 145

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 89489

Whenever your migrations get messed up, especially early in a project, just delete the migrations folder, drop the Migration History table and start fresh with a new initial migration.

Upvotes: 1

Related Questions