Skip to content

Twenty Eight Twelve

not quite exactly in the service of the crown

About Me

My name is Bevan Loon. I'm a software developer currently working in public health. I live in London with my wife and daughter. I used to play guitar.

Most Popular

  • Django REST Framework - Could not resolve URL for hyperlinked relationship using view name
  • Everything I know about the command line I learned from from Tron Legacy

Archives

Tag: ef code first

Upgrading EF 4.1 to EF 4.3 and Cannot scaffold the next migration errors

If you’ve somehow been volunteered to upgrade a project that was using Entity Framework 4.1 to Entity Framework 4.3 and you are trying in vain to get the new Code First Migrations to work, the simplest solution I’ve come across so far is to simply delete the EdmMetadata table in your database.

Usually, you’ll find yourself getting the following error when you run the “Update-Database” command in the Package Manager Console:

Cannot scaffold the next migration because the target database was created with a version of Code First earlier than EF 4.3 and does not contain the migrations history table. To start using migrations against this database, ensure the current model is compatible with the target database and execute the migrations Update process. (In Visual Studio you can use the Update-Database command from Package Manager Console to execute the migrations Update process).

There are some solutions posted already, but the caveat with these is that you have to run the “Add-Migration InitialMigration -IgnoreChanges” before you make any changes to your models. Woops. RTFM, I guess.

Anyway, deleting EdmMetadata manually and then running the “add-migration initialmigration -ignorechanges” seemed to do the trick.

Posted on March 16, 2012Categories ASP.NET MVC3, UncategorizedTags asp.net mvc, edmmetadata, ef 4.1, ef 4.3, ef code first, migrations, scaffold
Proudly powered by WordPress