I just finished modifying my models, launched "Update-Database" in the package manager console and BOOM! I got a "Sequence contains more than one element" error. When scanning through the console, he said No pending explicit migrations. , which is obviously not true since I renamed some models. I also found a call to SingleOrDefault , I don't know where it came from. I commented on my seed method so as not to call it
No pending explicit migrations. System.InvalidOperationException: Sequence contains more than one element at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<>c__DisplayClass280.<IndexesEqual>b__27d(String c) at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.IndexesEqual(ConsolidatedIndex consolidatedIndex1, ConsolidatedIndex consolidatedIndex2, ICollection`1 renamedColumns) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.<>c__DisplayClass271.<FindAddedIndexes>b__26d(ConsolidatedIndex i1, ConsolidatedIndex i2) at System.Data.Entity.Utilities.DynamicEqualityComparer`1.Equals(T x, T y) at System.Linq.Set`1.Find(TElement value, Boolean add) at System.Linq.Enumerable.<ExceptIterator>d__72`1.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(ModelMetadata source, ModelMetadata target, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) at System.Data.Entity.Migrations.Infrastructure.EdmModelDiffer.Diff(XDocument sourceModel, XDocument targetModel, Lazy`1 modificationCommandTreeGenerator, MigrationSqlGenerator migrationSqlGenerator, String sourceModelVersion, String targetModelVersion) at System.Data.Entity.Migrations.DbMigrator.IsModelOutOfDate(XDocument model, DbMigration lastMigration) at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b() at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration) at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run() at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate) at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner) at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force) at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command) Sequence contains more than one element
EDIT After some digging, it turned out that an error occurs when EF queries the _MigrationHistory table. but shouldn't he expect entries since I want to update the schema?
Also, does moving models affect another project?
EDIT AGAIN I'm tired of looking for what causes the problem, so I made a quick workaround
- Back up the script data
- Delete current database
- executed the Add-Migration and Update-Database command in the console
- Renamed table names in the backup script respectively
- Edit the script
Now everything works fine. You just need to find out why loading sooooooooooooo is annoyingly slow