updating migration while removing a column

Mckiky 21 Reputation points
2022-11-30T11:34:54.217+00:00

265714-stack-1.png265685-stacksite.png

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.

ASP.NET Core
ASP.NET Core
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
    2022-12-01T03:24:35.9+00:00

    Hi @Mckiky ,

    265957-image.png

    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,
    Dillion

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Mckiky 21 Reputation points
    2022-11-30T14:08:41.967+00:00

    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
    2022-12-02T10:01:42.97+00:00

    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.
    Thanks

    0 comments No comments