Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework migrations stopped detecting the POCO updates

I'm using Entity Framework and Entity Framework migrations to implement solution using code-first and automatic migrations.

It used to work great but suddenly it stopped detecting the updates I make to my POCO. Now when I add a new property (very simple properties like age or email) and execute the Update-Database, nothing happens, and it gives me this:

Specify the '-Verbose' flag to view SQL commands being executed during migration.
Found 0 pending explicit migrations: [].
Adding seed data (if Seed method overridden in Migrations Settings class).

and nothing gets updated!

Has anyone any idea why this is happening?

like image 490
Stacker Avatar asked Dec 13 '11 14:12

Stacker


1 Answers

This may be in two reasons:

  1. There is some other DbContext in code, that's why automatic migrations could not decide, which context to use.
  2. There is some new change, which loops a comparison of schema and code model, so EF simply could not find the difference.

In general, automatic migrations are simple and fast to implement, but it is not secured to use them. On some stage, such migrations could make a fail.

Several years ago, I have developed tiny ORM based on Linq2SQL, AcroDB Library, and it was using automigrations of SubSonic. Almost same as EF migrations can do now. It was perfect on small projects and small amount of data to process or change, but when project has grow into 15+ tables, it became a nightmare. That's why MS has announced Code-driven migrations lately. They are more secured and better for the project. Also, you can take a look to Migrator.Net (it is a bit better than EF, by this time).

like image 78
Oleksii G. Avatar answered Oct 18 '22 14:10

Oleksii G.