In short, to make all things, are DbContext managed state
1, check out, change, and then submit
2, new out, attach, then change, and then submit
Both of the above are better understood
3, new out, changed, and then attach, in the state of change, and then submit
Change state here, it is not the same as the normal property (X=>x.?). Ismodify=true, navigation properties cannot be used in this way
Because the navigation property corresponds to a collection, and the state is to correspond to the specific state of each element in the collection, rather than the entire state of the collection
((iobjectcontextadapter) db). ObjectContext.ObjectStateManager.ChangeRelationshipState (sourceentitytargetentity, Navigationpropertyselector, relationshipstate);
The statement is slightly cumbersome
Object of the first primary table
The second is a specific object in the Navigation property collection
The third is the navigation property of the primary Table object x=>x. Properties
The last one is the state
EF Update Navigation Properties