Specifies how objects being loaded into the object context are merged with objects already in the object context.
public enum class MergeOption
public enum MergeOption
type MergeOption =
Public Enum MergeOption
|AppendOnly AppendOnly AppendOnly AppendOnly||0||
Objects that do not exist in the object context are attached to the context. If an object is already in the context, the current and original values of object's properties in the entry are not overwritten with data source values. The state of the object's entry and state of properties of the object in the entry do not change. AppendOnly is the default merge option.
|NoTracking NoTracking NoTracking NoTracking||3||
Objects are maintained in a Detached state and are not tracked in the ObjectStateManager. However, Entity Framework-generated entities and POCO entities with proxies maintain a reference to the object context to facilitate loading of related objects.
|OverwriteChanges OverwriteChanges OverwriteChanges OverwriteChanges||1||
Objects that do not exist in the object context are attached to the context. If an object is already in the context, the current and original values of object's properties in the entry are overwritten with data source values. The state of the object's entry is set to Unchanged, no properties are marked as modified.
|PreserveChanges PreserveChanges PreserveChanges PreserveChanges||2||
Objects that do not exist in the object context are attached to the context.
The Entity Framework only maintains a single instance of an object with a specific entity key in the cache. The EntityKey objects are immutable objects that that represent object's identity. Entity keys are used to perform identity resolution in the object context. For more information, see Working with Entity Keys. If an entity with the same identity is already being tracked, the data coming from the data source and the data already in the state manager are merged according to the MergeOption of the query.