Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-create tables of EF CodeFirst from command package manager console

I use EF CodeFirst and would like to recreate tables in database using command line from package manager console, how to do that?

The problem is that while developing a EF CodeFirst models changes often and I delete tables in database manually and then EF recreate them on first run. To delete tables manually takes time and I think it should be a command which recreate tables from scratch in EF.

like image 532
Tomas Avatar asked Jan 09 '14 09:01

Tomas


1 Answers

You can use Update-Database -Target 0 to revert your database to it's initial state and then Update-Database to update your database to the latest version.

like image 134
Lukas Kabrt Avatar answered Sep 30 '22 16:09

Lukas Kabrt