Entity Framework: Re-finding objects recently added to context

The newly added object is in the local DataSource, since it’s not persisted yet in the database,

so you may say:

EntityObject search = ents.EntityObject.FirstOrDefault(o => o.Id == theId) ??
                      ents.EntityObject.Local.FirstOrDefault(o => o.Id == theId);

Leave a Comment