c# - EF - "Update-Database" causing Sequence contains more than one element -


i have finished modifying models, ran "update-database" in package manager console , boom! received "sequence contains more 1 element" error. upon scanning through console, did no pending explicit migrations. wrong since renamed models. found singleordefault call don't know came from. commented out seed method that's not causing it

    no pending explicit migrations. system.invalidoperationexception: sequence contains more 1 element    @ system.linq.enumerable.singleordefault[tsource](ienumerable`1 source)    @ system.data.entity.migrations.infrastructure.edmmodeldiffer.<>c__displayclass280.<indexesequal>b__27d(string c)    @ system.linq.enumerable.<>c__displayclass7_0`3.<combineselectors>b__0(tsource x)    @ system.linq.enumerable.whereselectenumerableiterator`2.movenext()    @ system.linq.enumerable.sequenceequal[tsource](ienumerable`1 first, ienumerable`1 second, iequalitycomparer`1 comparer)    @ system.data.entity.migrations.infrastructure.edmmodeldiffer.indexesequal(consolidatedindex consolidatedindex1, consolidatedindex consolidatedindex2, icollection`1 renamedcolumns)    @ system.data.entity.migrations.infrastructure.edmmodeldiffer.<>c__displayclass271.<findaddedindexes>b__26d(consolidatedindex i1, consolidatedindex i2)    @ system.data.entity.utilities.dynamicequalitycomparer`1.equals(t x, t y)    @ system.linq.set`1.find(telement value, boolean add)    @ system.linq.enumerable.<exceptiterator>d__72`1.movenext()    @ system.linq.enumerable.whereselectenumerableiterator`2.movenext()    @ system.collections.generic.list`1..ctor(ienumerable`1 collection)    @ system.linq.enumerable.tolist[tsource](ienumerable`1 source)    @ system.data.entity.migrations.infrastructure.edmmodeldiffer.diff(modelmetadata source, modelmetadata target, lazy`1 modificationcommandtreegenerator, migrationsqlgenerator migrationsqlgenerator, string sourcemodelversion, string targetmodelversion)    @ system.data.entity.migrations.infrastructure.edmmodeldiffer.diff(xdocument sourcemodel, xdocument targetmodel, lazy`1 modificationcommandtreegenerator, migrationsqlgenerator migrationsqlgenerator, string sourcemodelversion, string targetmodelversion)    @ system.data.entity.migrations.dbmigrator.ismodeloutofdate(xdocument model, dbmigration lastmigration)    @ system.data.entity.migrations.dbmigrator.upgrade(ienumerable`1 pendingmigrations, string targetmigrationid, string lastmigrationid)    @ system.data.entity.migrations.infrastructure.migratorloggingdecorator.upgrade(ienumerable`1 pendingmigrations, string targetmigrationid, string lastmigrationid)    @ system.data.entity.migrations.dbmigrator.updateinternal(string targetmigration)    @ system.data.entity.migrations.dbmigrator.<>c__displayclassc.<update>b__b()    @ system.data.entity.migrations.dbmigrator.ensuredatabaseexists(action mustsucceedtokeepdatabase)    @ system.data.entity.migrations.infrastructure.migratorbase.ensuredatabaseexists(action mustsucceedtokeepdatabase)    @ system.data.entity.migrations.dbmigrator.update(string targetmigration)    @ system.data.entity.migrations.infrastructure.migratorbase.update(string targetmigration)    @ system.data.entity.migrations.design.toolingfacade.updaterunner.run()    @ system.appdomain.docallback(crossappdomaindelegate callbackdelegate)    @ system.appdomain.docallback(crossappdomaindelegate callbackdelegate)    @ system.data.entity.migrations.design.toolingfacade.run(baserunner runner)    @ system.data.entity.migrations.design.toolingfacade.update(string targetmigration, boolean force)    @ system.data.entity.migrations.updatedatabasecommand.<>c__displayclass2.<.ctor>b__0()    @ system.data.entity.migrations.migrationsdomaincommand.execute(action command) sequence contains more 1 element 

edit after digging, found out error occurs when ef queries _migrationhistory table. shouldn't expect records since want update schema?

also, moving models project have effect?

edit again got tired of finding causing problem did quick workaround

  1. create backup script of data
  2. delete current database
  3. ran add-migration , update-database in console
  4. renamed table names in backup script accordingly
  5. ran script

all working fine now. have figure out why loading sooooooooooooo annoyingly slow


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -