Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"update-database" Entity framework code first doesn't add tables anymore

I'm using Entity Frame work 5 code first in my website. Every thing was fine and I've been using

update-database -verbose

to update database with new data or new structure and model, however; out of no where update-database has stopped working and it doesn't track changes in model and new tables anymore.

I have searched over internet and some say that I have to delete database context and recreate it to make it work. I can't do this, the project is kind of big and more than 4k lines would be affected if I delete the database context.

I'm using visual studio 2012 with the 3rd update, so update is not the solution either.

any suggestions.

like image 786
Daniel Avatar asked Feb 01 '26 04:02

Daniel


1 Answers

as I told you deleting the database context didn't fix my problem. This is how I fixed the issue. I dropped table __MigrationHistory using sql command and run the update-database -verbose again.

Apparently something was wrong with this automatic created table.

like image 51
Daniel Avatar answered Feb 04 '26 01:02

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!