Click here to Skip to main content
15,907,000 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I am working on a E-Commerce application in C#.
I am following this tutorial on Youtube:

When I do Migrations for each of the Tables in the ApplicationDBContext, the Migrations are empty. When I attempt to Update-Database, the Tables are not added to the Database.

How can I succesfully create and add these Migrations to the Database?


Product.cs Class

AddproductModel Migration

What I have tried:

Initially, I had created migrations for each of the tables/classes associated with the ApplicationDBContext.

These Migrations created a error when I had run Update-Database. So I deleted Migrations and the database and then re-created them both. Now Migration files are empty and the Tables are nowhere to be found in the Database
Updated 8-Nov-22 23:44pm

1 solution

Deleting the migration files won't be enough. You also need to delete the "model snapshot" that's used to compute the difference between the last migration generated and the current model.

The simplest option would probably be to delete the entire "migrations" folder from your project.
Share this answer
Keshav Mooruth 10-Nov-22 5:09am    
Thanks Richard. I deleted the Migrations folder and re-created the Migrations, which worked to fix the problem. THANKS for your help!!!
@Richard Deeming

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900