Change the IDENTITY property of a column, the column needs to be dropped and recreated

I ran into the same problem, and I solved it by two steps and two migrations:

Step 1

  1. Drop the identity column.
  2. Comment the ID in BankAccount and add a new one (i.e., BankAccountId as
    identity, add migration and update – this drops id).
  3. Add a new column as identity.

Step 2

  1. Drop the newly added column and re-add the previous one.
    Comment BankAccountId and un-comment ID.
  2. Add migration and update (this drops the BankAccountId and adds Id as identity).

Leave a Comment