Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Deleted local database tables using SSMS and can't recreate it with ASP.NET Entitiy Framework

I’ve been a bit gung ho and deleted my database tables using SQL Server Management Studio (SSMS) and deleted all the migrations manually too.

The database is local and was for testing purposes only. How can I create the tables again with Entity Framework?

If it involves a lot of work am I better starting a fresh ASP.NET app and copying across my code?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to start with one fresh migration because you didn’t deploy your app yet, you can:

  1. Remove the Migrations directory including its snapshot and migration files.
  2. Create a new migration: dotnet ef migrations add Initial
  3. Update your database: dotnet ef database update

This will generate one migration and initalize the database according to the current state of your entities.


If you only deleted your database but still have your migrations, getting a fresh one is as simple as:

dotnet ef database update
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading