Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Code First Migration Seed Method without a migration

How do you run a code first entity framework migration without changing anything in the datamodel which would cause a migration to be created? I just want to run the seed method again because I added things to it.

like image 488
Jhayes2118 Avatar asked Feb 26 '15 14:02

Jhayes2118


People also ask

What is the purpose of the seed method in migrations?

Seed method is used to initialized the database tables with some starting data. Whenever you run the migration and update the database it will run the seed method. Mostly it is used during the testing phase where you often need to recreate the database and populate database tables with sample data.


1 Answers

If you just need to run Seed() again, and nothing has changed that would cause a new migration to be added, just call Update-Database again with no flags and it will say 'No pending migrations', and run Seed() again for you. Seed() is called every time the DB is updated, regardless if there are new migrations or not.

like image 136
DrewJordan Avatar answered Sep 28 '22 18:09

DrewJordan