Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7501287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:28:43+00:00 2026-05-29T20:28:43+00:00

I upgraded a project to Entity Framework 4.3 and enabled migrations on the project.

  • 0

I upgraded a project to Entity Framework 4.3 and enabled migrations on the project.

However, I get this error when running the Update-Database command:

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).

Basically, it is telling me to run the same command (Update-Database) that is giving me the error.

Any ideas?


Not exactly a “fun” way to do it, but I let the app create a new database, which creates a system table called “__MigrationHistory”. I then ran the following script to create that table on my old database. I also created a script to copy the one row that existed in the new database to the old database.

If someone from Microsoft or community knows a more efficient way of doing this, please post here!


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[__MigrationHistory](
    [MigrationId] [nvarchar](255) NOT NULL,
    [CreatedOn] [datetime] NOT NULL,
    [Model] [varbinary](max) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
 CONSTRAINT [PK___MigrationHistory] PRIMARY KEY CLUSTERED 
(
    [MigrationId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF,         ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:28:45+00:00Added an answer on May 29, 2026 at 8:28 pm

    When you ran Enable-Migrations, the scripts may have not created an initial migration, especially if your model was mismatched to the database, or if your DbContext class is defined in a different project.

    I’m not sure what the “right way” to add migrations to an existing pre-4.3 database is, but the easiest way is to dump your database. Drop the tables in it…

    Make sure the Configuration file in the Migrations folder has the right context type, and then Add-Migration Initial. A big class will get built, representing your current model.

    Now Update-Database will run without complaining.


    If you have data that you care about in the db, you may be able to cheat and add the __MigrationHistory table that the migrations process creates to a previous backup of your database. Delete the EdmMetadata and migrations shouldn’t be any wiser.

    Hopefully someone who actually knows how migrations were intended to be added to an existing EF Code First database will have smoother upgrade steps?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've inherited a legacy J++ project. I've upgraded this project to standard Sun Java
I'm starting a new project and the client wants to use the Entity Framework
I've upgraded a WCF project running 3.5 vs2008 to .net 4.0 vs2010 and run
How do I upgrade an existing VS2010 ASP.Net 3.5 project from Entity Framework 3.5
I upgraded a MVC1 project to MVC2, now all my calls to RenderPartial are
My current project involves deploying an upgraded .exe file that runs as a Windows
I recently upgraded a VS2005 web deployment project to VS2008 - and now I
I just upgraded a VS 2005 project to VS 2008 and was examining the
I've just upgraded a native C++ project from VS2005-SP1 to VS2008-SP1 The first thing
I recently upgraded a Web Application Project (as well as some dependent projects) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.