I am trying to run migrations with custom DbContext.
var migrationConfiguration = new DbMigrationsConfiguration { AutomaticMigrationsEnabled = true };
migrationConfiguration.ContextType = typeof(DataContext);
var migrator = new DbMigrator(migrationConfiguration);
migrator.Update();
This throws Migration Exception, because DataContext
does not implement parameterless constructor:
The target context 'System.Data.Entity.DbContext' is not constructible. Add a default constructor or provide an implementation of IDbContextFactory.
The DataContext
constructor requires parameters, but I already have IDbContextFactory<DataContext>
created. How do I tell DbMigrator, to use existing implementation of IDbContextFactory<DataContext>
?