I was running successfully Entity framework 6.0.0-alpha3
until today. Today I decided to update to Entity framework 6.0.0-rc1
, and as specified here in order to run my migrations I need to remove all the previous migrations made by ef alpha1-alpha3
and remake them.
Since all my migrations were made by alpha3
, I decided to drop all the migrations (including _MigrationHistory table), and re-enable it.
I created initial migration with add-migration Initial -IgnoreChanges
(which has empty Up()
and Down()
methods), then I executed update-database
, and I thought, that everything is okay. Well, its not. When I am adding new class to my model, add-migration first
creates migration with empty Up()
and Down()
methods.
Also, previously, when I wanted to access object that wasn't yet registered with migrations, I was receiving an error saying that I need to update my migrations. Now, when I try to access the new object, it simply says "Invalid object name 'dbo.Notifications'."
.
What do I do now?
EF uses a snapshot of the database model (which is saved along with the migration) to determine changes between current version of your database model and the last migration.
add-migration Initial -IgnoreChanges
command creates a migration with the snapshot of your database model, but it ignores any changes from previous database snapshot (i.e. empty database) because you are telling to do so.
add-migration First
command looks at previous migration (i.e. Initial) and compares the current database model snapshot with the snapshot form the Initial
migration. Obviously these snapshots are the same, so Up()
and Down()
methods are empty.
I think the solution for your problem is to generate all changes in the Initial migration
add-migration Initial