updating migration while removing a column

Mckiky 21 Reputation points


hello, I am using visual studio with SQL server, i am in a middle of a practice and faced a major issue. The issue is in the first place, while i was creating a product table, by mistake i typed as a category ctegoryId, and later i recorrected it by thinking its over.

And now I am almost done with the identity scaffolding when updating my database, I faced such an error. and I've tried all ways to update the issue but failed. I need an expert guidance so I can continue my path till the end.

I do appreciate any solution from your side.

A set of technologies in the .NET Framework for building web applications and XML web services.
4,360 questions
SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
509 questions
0 comments No comments
{count} votes

Accepted answer
  1. Zhi Lv - MSFT 32,076 Reputation points Microsoft Vendor

    Hi @Mckiky ,


    About this issue, you can try to delete the AddProductToDatabase migration file, and open the ApplicationDbContextModelSnapshot.cs file to remove the relates code about create the Product Entity.

    Then, running the EF core Migration command add-migration AddProductToDatabase to generate the migration file again, after that use update-database command to generate the table.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Mckiky 21 Reputation points

    By the way , when i try loading my project, i face the above error.265677-error-of-category.png

    Please if someone could help me solve my issue.

  2. Mckiky 21 Reputation points

    Thanks a lot.
    I have deleted my migration and reinstalled it again. Plus i have noticed i made [NotMapped]in my product table CategoryId.
    So i had to remove that too, and everything went back to normal.

    0 comments No comments