Export (0) Print
Expand All
Expand Minimize
2 out of 3 rated this helpful - Rate this topic

EntityState Enumeration

The state of an entity object.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Data
Assembly:  System.Data.Entity (in System.Data.Entity.dll)
[<BindableTypeAttribute(IsBindable = false)>]
[<FlagsAttribute>]
type EntityState
Member nameDescription
AddedThe object is new, has been added to the object context, and the SaveChanges method has not been called. After the changes are saved, the object state changes to Unchanged. Objects in the Added state do not have original values in the ObjectStateEntry.
DeletedThe object has been deleted from the object context. After the changes are saved, the object state changes to Detached.
DetachedThe object exists but is not being tracked. An entity is in this state immediately after it has been created and before it is added to the object context. An entity is also in this state after it has been removed from the context by calling the Detach method or if it is loaded by using a NoTracking MergeOption. There is no ObjectStateEntry instance associated with objects in the Detached state.
ModifiedOne of the scalar properties on the object was modified and the SaveChanges method has not been called. In POCO entities without change-tracking proxies, the state of the modified properties changes to Modified when the DetectChanges method is called. After the changes are saved, the object state changes to Unchanged.
UnchangedThe object has not been modified since it was attached to the context or since the last time that the SaveChanges method was called.

The object context must know the state of an object to save changes back to the data source. ObjectStateEntry objects store EntityState information. The SaveChanges methods of the ObjectContext process entities that are attached to the context and update the data source depending on the EntityState of each object. For more information, see Adding, Modifying, and Deleting Objects.

The state of objects inside an object context is managed by the ObjectStateManager. To find out the state of an object, call one of the following ObjectStateManager methods: TryGetObjectStateEntry, GetObjectStateEntry, or GetObjectStateEntries. The State property of the ObjectStateEntry defines the state of the object.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.