3

We use Entity Framework 6.0 and added a new table using Code First. As usual, we created the EntityMap and added the entity and the map to the context. When we try to upgrade the database using the package manager console command "update-database -script", EF wants to apply all migrations (including the ones that are already in the __MigrationHistory table).

Has anyone experienced the same issue and knows how to solve it?

Thanks in advance

4
  • 1
    Does adding -Verbose to the command illuminate the cause? Commented Apr 2, 2015 at 13:29
  • Did you run the prior migrations without -script so they are applied? You could try adding the -SourceMigration and -TargetMigration options. msdn.microsoft.com/en-us/data/jj591621.aspx#script Commented Apr 2, 2015 at 13:30
  • thanks @Amy, the -Verbose command lead us to the solution of specifying -StartUpProjectName Commented Apr 2, 2015 at 13:35
  • Glad it all worked out! Commented Apr 2, 2015 at 13:52

1 Answer 1

3

We found the issue thanks to the comment of @Amy... When adding the Parameter -Verbose, it became clear that the migrations will be applied to a (new) localDb. We didn't specify the -StartUpProjectName and assumed, it will be the selected default Project. After the -StartUpProjectName was set, everything worked fine :-)

Sign up to request clarification or add additional context in comments.

1 Comment

There are several ways this can happen, e.g. wiping out local code and re-retrieving from source control (startup project gets lost) or switching the startup project to a secondary project to debug it (forgetting to switch back).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.