How to get a reference to superior object from Entity object
How to get a reference to superior ObjectContext from EntityObject class?
Only way you can do it is via a hack using relationships, and an entity that is not detached. See below.
YourEntity someEntity = null; RelationshipManager relationshipManager = ((IEntityWithRelationships)someEntity ).RelationshipManager; IRelatedEnd relatedEnd = relationshipManager.GetAllRelatedEnds().FirstOrDefault(); ObjectQuery getContext = relatedEnd.CreateSourceQuery() as ObjectQuery; YoutObjectContext c1 = (YourObjectContext)getContext .Context;
Good luck with it. If you use the code above i recommend protecting it with null checks.
Have a look at the following link:
It is like the way that Nix mentioned as an extenxtion to the entity object.