Entity Framework Code First “Unable to generate an explicit migration because the following explicit migrations are pending”

I ran into this error “Unable to generate an explicit migration because the following explicit migrations are pending”.

Common causes include:

  1. You really have some pending migrations.  You can do “update-database –verbose” to apply the pending migrations.
  2. Your solution have multiple projects (e.g. WebAppProject, DataModelProject) and the wrong project is set as the start up project.  So just go to Visual Studio and select the right project and then set it as a startup project.
  3. You changed the ContextKey value in the Migrations\Configuration.cs.  You can always check the [dbo].[__MigrationHistory] entries to see if the ContextKeys match.  If Configuration.cs does not have a ContextKey, that should be fine.
Advertisements