.net - InvalidOperationException in Mobile Service Initialization -


i working on azure mobile service .net backend. started having problems in seed method when publishing service.

collection modified; enumeration operation may not execute. description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.   exception details: system.invalidoperationexception: collection modified; enumeration operation may not execute. 

it points line 196

        line 182: foreach (service s in listservices.toarray())         line 183: {         line 184:     context.services.add(s);         line 185: }         line 186: foreach (client c in listclient.toarray())         line 187: {         line 188:     context.clients.add(c);         line 189: }         line 190: foreach (employee e in listemployees.toarray())         line 191: {         line 192:     context.employees.add(e);         line 193: }         line 194: foreach (calendar c in listcalendar.toarray())         line 195: {         line 196:       context.calendars.add(c);         line 197: }         line 198: //context.calendars.add(cal1); 

why getting problem here, when couple of lines before, add other objects? see complains because of connection string, went ahead , created database , copied wole connection string properties page.

still no luck, tho.

this started happening, when started adding more objects context. in beginning 6 or objects (of different types), got added database.

right schema gets created, no data added. ideas please?

stacktrace:

[invalidoperationexception: collection modified; enumeration operation may not execute.]    system.throwhelper.throwinvalidoperationexception(exceptionresource resource) +52    system.collections.generic.enumerator.movenextrare() +11013833    system.collections.generic.enumerator.movenext() +64    system.data.entity.core.objects.entityentry.takesnapshotofrelationships() +705    system.data.entity.core.objects.internal.entitywrapperwithoutrelationships`1.takesnapshotofrelationships(entityentry entry) +36    system.data.entity.core.objects.objectcontext.addsingleobject(entityset entityset, ientitywrapper wrappedentity, string argumentname) +311    system.data.entity.core.objects.objectcontext.addobject(string entitysetname, object entity) +327    system.data.entity.internal.linq.<>c__displayclassd.<add>b__c() +98    system.data.entity.internal.linq.internalset`1.actonset(action action, entitystate newstate, object entity, string methodname) +355    system.data.entity.internal.linq.internalset`1.add(object entity) +200    system.data.entity.dbset`1.add(tentity entity) +131    adapptacjaservice.mobileserviceinitializer.seed(mobileservicecontext context) in c:\adapptacja\windowsuniversal\adapptacjauniversal\adapptacjaservice\app_start\webapiconfig.cs:196    system.data.entity.createdatabaseifnotexists`1.initializedatabase(tcontext context) +302    microsoft.windowsazure.mobile.service.cleardatabaseschemaalways`1.initializedatabase(tcontext context) +173  [invalidoperationexception: database initialization failed. not initialize 1 or more objects in schema 'adapptacja'. please ensure database connection string correct. more details on error, please see inner exception.]    microsoft.windowsazure.mobile.service.cleardatabaseschemaalways`1.initializedatabase(tcontext context) +314    system.data.entity.internal.<>c__displayclassf`1.<createinitializationaction>b__e() +165    system.data.entity.internal.internalcontext.performinitializationaction(action action) +110    system.data.entity.internal.internalcontext.performdatabaseinitialization() +660    system.data.entity.database.initialize(boolean force) +61    adapptacjaservice.webapiconfig.register() in c:\adapptacja\windowsuniversal\adapptacjauniversal\adapptacjaservice\app_start\webapiconfig.cs:28    adapptacjaservice.webapiapplication.application_start() in c:\adapptacja\windowsuniversal\adapptacjauniversal\adapptacjaservice\global.asax.cs:10  [httpexception (0x80004005): database initialization failed. not initialize 1 or more objects in schema 'adapptacja'. please ensure database connection string correct. more details on error, please see inner exception.]    system.web.httpapplicationfactory.ensureappstartcalledforintegratedmode(httpcontext context, httpapplication app) +9918021    system.web.httpapplication.registereventsubscriptionswithiis(intptr appcontext, httpcontext context, methodinfo[] handlers) +118    system.web.httpapplication.initspecial(httpapplicationstate state, methodinfo[] handlers, intptr appcontext, httpcontext context) +172    system.web.httpapplicationfactory.getspecialapplicationinstance(intptr appcontext, httpcontext context) +336    system.web.hosting.pipelineruntime.initializeapplication(intptr appcontext) +296  [httpexception (0x80004005): database initialization failed. not initialize 1 or more objects in schema 'adapptacja'. please ensure database connection string correct. more details on error, please see inner exception.]    system.web.httpruntime.firstrequestinit(httpcontext context) +9931916    system.web.httpruntime.ensurefirstrequestinit(httpcontext context) +101    system.web.httpruntime.processrequestnotificationprivate(iis7workerrequest wr, httpcontext context) +254 


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -