none
where migrations are stored in EF 5? RRS feed

  • Question

  • Hello

     I have deleted development database and Migrations folder only have Configuration.cs . After call Add-Migration -IgnoreChanges I still get

    Unable to generate an explicit migration because the following explicit migrations are pending: [201302201810047_InitialCreate, 201302201840012_wieleDoWielu]. Apply the pending explicit migrations before attempting to generate a new explicit migration.

    So, there those migration are stored?

    Friday, February 22, 2013 2:46 PM

Answers

  • Hi I think the problem was that, if every time I started unit test this one runs with compiled library which has Migration files. So update from project where was no those files takes migration info from database. I really don't know. At fist computer run at Monday everything just works fine
    Tuesday, February 26, 2013 6:21 PM

All replies

  • Hi,

    The only reason that I can think of for you to get this exception is if the migrations it is referring to are still in the assembly when you run the app. Are you sure there aren't migrations somewhere else in the project, not in the migrations folder?

    Some testing on my machine just verified that deleting all my migrations stopped this exception from occurring, so if it is still happening and you are sure there are no migrations, then could you maybe send me the solution?


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Friday, February 22, 2013 11:37 PM
    Moderator
  • Hi,

    I can't send the solution. It's project in my job.

    Project is connected to Team Foundation Server, but if I look into folder there are no files that could be migrations.

    At the beginning project was using default (local..something)\v11.0 server and target database was different but then I corrected it on two ways by passing connections string into dbContext class and also change in App.config.

    In the solution I have few project where one of them is unit test. So after created database via run unit test it differ from database created via Update-Database when project that have source files for dbContext is set as start up and PM is used on him. Database created via run test is more complete then this from Update-Database. So if Migrations folder is deleted info about migrations is stored only in sys table __MigrationHistory. Am I right?

    Best Regards

    Przemysław Staniszewski




    Saturday, February 23, 2013 12:00 PM
  • You are right that if you delete all the migrations from your assembly then the only place that stores them is the MigrationHistory system table. But it doesn't store the actual migration, just its name and a hash of what the model was when the migration was run.

    Does that help with your problem though, I thought you had deleted both the database and the migrations and still got the error?


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Tuesday, February 26, 2013 5:42 PM
    Moderator
  • Hi I think the problem was that, if every time I started unit test this one runs with compiled library which has Migration files. So update from project where was no those files takes migration info from database. I really don't know. At fist computer run at Monday everything just works fine
    Tuesday, February 26, 2013 6:21 PM
  • If there are different migrations in the unit tests to the main application then that might cause your problem I guess.

    I'm not really sure what the root cause of it is at this point though. I'll mark your previous post as the answer, since the problem has gone away now, if it comes back then feel free to post here again and we'll look at it more.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Tuesday, February 26, 2013 7:04 PM
    Moderator