I am trying to perform migrations using a custom DbContext.
var migrationConfiguration = new DbMigrationsConfiguration { AutomaticMigrationsEnabled = true };
migrationConfiguration.ContextType = typeof(DataContext);
var migrator = new DbMigrator(migrationConfiguration);
migrator.Update();
This eliminates the migration exception because it DataContextdoes not implement the constructor without parameters:
The target context "System.Data.Entity.DbContext" is not constructive. Add a default constructor or provide an implementation of IDbContextFactory.
The constructor DataContextrequires parameters, but I already have IDbContextFactory<DataContext>. How to tell DbMigrator to use an existing implementation IDbContextFactory<DataContext>?
source
share