Question

I have an existing dev DB with schema and data. I created the classes using the microsoft utility (CodeFirst classes that is). I then enabled migrations.

Now I'm puzzled about the behaviour of -IgnoreChanges. If the initial migration has no Up() and no Down() logic, what will happen when I deploy to a prod db?

Does EF simply ignore all migrations and just build from scratch directly from the model?

If I don't put in -IgnoreChanges, all the Up() and Down() logic is there. But upon Update-Database, it throws an exception about a table with the same name already existing.

I'm using EF 5 RC.

Was it helpful?

Solution

IgnoreChanges is for scenarios where you have existing application (in both dev and prod) and you want to start using migrations. IgnoreChanges will simplify adding initial migration to existing database. If you are in scenario where no production database exist you cannot use Ignore changes.

The straightforward option for your case is creating entities from existing database and continue working on another database created by your migration from those entities because you need table creation for all those entities in Up method (and Down method respectively).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top