Code First Migration in Multiple DbContext

Package Manager Console – Commands

  • enable-migrations -ContextTypeName <DbContext-Name-with-Namespaces> -MigrationsDirectory:<Migrations-Directory-Name>
  • add-migration -configuration <DbContext-Migrations-Configuration-Class-with-Namespaces> <Migrations-Name>
  • update-database -configuration <DbContext-Migrations-Configuration-Class-with-Namespaces> -Verbose

Samples

  • enable-migrations -ContextTypeName App1.Model.App1DataModel -MigrationsDirectory:MigrationApp1Data
  • update-database -configuration:App1.MigrationApp1Cache.Configuration

More info in Data Developer Center

Code First Migrations