CodeFirst Two Context in Migrations RRS feed

  • Question

  • User-2028158708 posted

    I've decided to separate my auth tables and data tables into different contexts. I created two migration Configurations, one for each context. Unfortunatly I can't successfully add migrations for the two data context. I create a migration for one context and update-database, the I try to create another migration for the other context, but I get a 'pending migration' error. Why is that? The database looks OK after update-database, and the version of the database is the version of pending migration... here is some log:

    PM> Add-Migration -ConfigurationTypeName ConfigurationAuth AuthInit
    Scaffolding migration 'AuthInit'.
    The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration AuthInit' again.
    PM> update-database -ConfigurationTypeName ConfigurationAuth -TargetMigration AuthInit
    Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
    Applying explicit migrations: [201806081231300_AuthInit].
    Applying explicit migration: 201806081231300_AuthInit.
    Running Seed method.
    PM> Add-Migration -ConfigurationTypeName Configuration DataInit
    Unable to generate an explicit migration because the following explicit migrations are pending: [201806081231300_AuthInit]. Apply the pending explicit migrations before attempting to generate a new explicit migration.

    What I am doing wrong?

    Friday, June 8, 2018 12:38 PM

All replies