ich habe mit dem EF6 eine Datenbank erstellt. Danach habe dann in einer Tabelle Spalten gelöscht. In der Paket-Manager-Console habe ich meine dll ausgewählt und
Enable-Migrations aufgerufen. Dann bekam ich die Meldung: Checking if the context targets an existing database... Detected database created with a database initializer. Scaffolded migration '201701011841233_InitialCreate' corresponding to existing database. To use an automatic migration instead, delete the Migrations folder and re-run Enable-Migrations specifying the -EnableAutomaticMigrations parameter. Code First Migrations enabled for project Manthey.EF_DB.
Die InitialCreate.cs beinhaltet auch das Schema der aktuellen Datenbank also alles ok. Dann habe ich das Projekt neu kompiliert.
Dann gebe ich Add-Migration Emplyees ein.
Nun bekomme ich folgende Exception: System.InvalidOperationException: The model backing the 'MaDBContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269). bei System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context) bei System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() bei System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) bei System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() bei System.Data.Entity.Database.Initialize(Boolean force) bei Manthey.EF_DB.DataBase.MaDBContext..ctor(String ConnectionString) in C:\Users\Ingo\Documents\Visual Studio 2015\Projects\MantheyWPF\Manthey.EF_DB\DataBase\MaDBContext.cs:Zeile 50. bei Manthey.EF_DB.DataBase.MaDBContext..ctor() in C:\Users\Ingo\Documents\Visual Studio 2015\Projects\MantheyWPF\Manthey.EF_DB\DataBase\MaDBContext.cs:Zeile 35. --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance() bei System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver) bei System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase) bei System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration) bei System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration) bei System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run() bei System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) bei System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) bei System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) bei System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges) bei System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges) bei System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0() bei System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) The model backing the 'MaDBContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
Kamm mir hier jemadn helfen?? Danke im voraus für jeden Hinweis und Tipp.
Der Name der Datei 201701011841233_InitialCreate ist der selbe wie die MigrationId in der Tabelle 201701011841233_InitialCreate
Ich habe habe ich ein Download bereit gestellt. Die Datenbank ist eine SQL-Server 2016 Datenbank. Hier habe ich das Code-First Project und eine Datensicherung der Datenbank für den SQL-Server 2016 bereit gestellt. http://www.IngoManthey.de/Downloads/EF6.rar
Geändert habe ich ContactEMails.cs einen string Test hinzugefügt. Wenn mann Add-Migration aufruft kommt der Fehler.