Tuesday, July 19, 2016

The entity type List`1 is not part of the model for the current context

where db is List

db.Entry(bd).State = EntityState.Modified;

DbContext.Entry(object) expects a single object, not a collection.

so use a loop instead

foreach (var item in bd)
{
    db.Entry(item).State = EntityState.Modified;
}

1 comment:

  1. how to update the whole list instead of updating the one by one item in the loop which is taking a lot of time to complete if the bd list is long such as 1 million.

    ReplyDelete