none
Entity Framework SaveChanges() throws Collection was modified; RRS feed

  • Question

  • Hi, I am trying simply to create some entities and save them to the database.
    And i get the following exception.
    I am guessing it is because my entities got circle references between them, but am not sure.
    In any case is it a bug?
    I am using VS 2010 RC
    Initialization method bla threw exception. System.InvalidOperationException: System.InvalidOperationException: Collection was modified; enumeration operation may not execute..
    at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
    at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
    at System.Collections.Generic.List`1.Enumerator.MoveNext()
    at System.Data.Objects.ObjectStateManager.PerformAdd(IList`1 entries)
    at System.Data.Objects.ObjectStateManager.DetectChanges()
    at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
    at System.Data.Objects.ObjectContext.SaveChanges()
    
    Monday, March 1, 2010 12:42 PM

Answers

  • Hi,

    Can you file a bug on Connect so we can have a look at what's causing this exception, please? Please be sure to include your model and the code you are using to call the Entity Framework.

    Thanks,
    David

    Blog - http://blogs.rev-net.com/ddewinter/ Twitter - @ddewinter
    Monday, March 1, 2010 10:21 PM
    Answerer