Question: How do you resolve the Entity Framework Error in Asp.Net Core 3.1: To change the IDENTITY property of a column, the column needs to be dropped and recreated
Login to See the Rest of the Answer
Answer: First of all, make sure that your ef core is up to date by updating the dotnet tools in Powershell using the command: dotnet tool update --global dotnet-ef
- After verifying the dotnet ef core is up to date, remove the migration using Powershell.
- to do this, you need to be in the project folder. CD into the project folder and run the following command:
- dotnet ef migrations remove --context SpecifyYourDatabaseContextIfYouHaveMoreThanOne
- dotnet ef update --context SpecifyYourDatabaseContextIfYouHaveMoreThanOne
If the commands are successful, go ahead and add a migration with your changes in the class modal
- dotnet ef migrations add NameOfMigration --context SpecifyYourDatabaseContextIfYouHaveMoreThanOne
[Note] Read about how to optimize Entity Framework for Performance here.