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 8835893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:21:58+00:00 2026-06-14T09:21:58+00:00

Now i’m using EF6 Alpha, and when using migration, it will add a new

  • 0

Now i’m using EF6 Alpha, and when using migration, it will add a new migration log into the __MigrationHistory table.

In EF6, The __MigrationHistory table has a new column called “ContextKey”. After testing, I found there are two default “ContextKey” value:

  1. The full name of DbContext’s derived class.This happens when i run the code:

    Database.CreateIfNotExists();
    
  2. The full name of DbMigrationsConfiguration’s derived class. This happens when i run the code:

    public ArticleDbContext()
    {   
        Database.SetInitializer(new MigrateDatabaseToLatestVersion<ArticleDbContext, ArticleConfiguration>());
    }
    

The first time i run the application, “Database.CreateIfNotExists();” create a new database for me, also all tables that map to the models defined in ArticleDbContext, and then add a __MigrationHistory row which ContextKey’s value is “Module.Article.Model.ArticleDbContext”.

And then “Database.SetInitializer(new MigrateDatabaseToLatestVersion());” will be runned, this code will generate a new ContextKey “PowerEasy.Module.Article.Migrations.ArticleConfiguration”. Migration query the __MigrationHistory table with this ContextKey and find out there’s no data. So again it will create all tables that map to the models defined in ArticleDbContext, but the tables are already exist in the database, so an exception will be throwed, and tell me “the table XXX is already existed”.

How can i solve this?

  • 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-06-14T09:21:59+00:00Added an answer on June 14, 2026 at 9:21 am

    You should not mix Migrations and the Database.CreateIfNotExists method (or any of the initializers built on top of it). Migrations will take care of creating the database if it does not already exist.

    As an alternative to the Migrations initializer, you can also apply migrations using the DbMigrator.Update method. This is useful if you want to create/update the database before it would otherwise be triggered by the initializer.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
now i am getting text in labels of table view when i update item
Now I have learnt a little bit of assembler (using NASM) I want to
Now I am exceptionally new to network programming so tell me if this is
Now that my facebook app has got more than 1000 likes -- https://apps.facebook.com/156485447732146/ But
Now I have 4 tables: table categories: -id -category table products: -id -product -price
Now this has no practical implications at all, but I am curious about this
Now ,I have two tables, Location and q_Location , location as main table .I
Now i am working in iPhone application, Using UIImageView to create a animation and

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.