Last post Jun 11, 2018 02:56 AM by Nan Yu
Jun 08, 2018 12:38 PM|redeativa|LINK
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
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?
Jun 11, 2018 02:56 AM|Nan Yu|LINK
Hi redeativa ,
Please check whether you have two configuration classes existed in the same namespace :
You can also refer to below article for how to enable multi data contexts in EF 6 code first :
Entity Framework 6 Code First Migrations with Multiple Data Contexts