Ich versuche, Migrationen mit benutzerdefiniertem DbContext auszuführen.Stellen Sie eine Implementierung von IDbContextFactory bereit. Aber wo?
var migrationConfiguration = new DbMigrationsConfiguration { AutomaticMigrationsEnabled = true };
migrationConfiguration.ContextType = typeof(DataContext);
var migrator = new DbMigrator(migrationConfiguration);
migrator.Update();
Dies wirft Migration Ausnahme, weil DataContext
nicht parameterlosen Konstruktor nicht implementiert:
Der Zielkontext 'System.Data.Entity.DbContext' nicht konstruierbar ist. Fügen Sie einen Standardkonstruktor hinzu oder stellen Sie eine Implementierung von IDbContextFactory bereit.
Der DataContext
Konstruktor erfordert Parameter, aber ich habe schon IDbContextFactory<DataContext>
erstellt. Wie sage ich DbMigrator, die vorhandene Implementierung von IDbContextFactory<DataContext>
zu verwenden?
Etwas anderes ist hier falsch - man beachte die ' System.Data.Entity.DbContext' (nicht 'DataContext') in der Ausnahmebedingungsnachricht. –
Zeigen Sie Ihren Kontext. http://stackoverflow.com/questions/11395283/how-to-implement-idbcontextfactory-for-use-with-entity-framework-data-migrations –