This documentation is archived and is not being maintained.

EntityKey.IsTemporary Property

Gets a value that indicates whether the EntityKey is temporary.

Namespace:  System.Data
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

public bool IsTemporary { get; }

Property Value

Type: System.Boolean
true if the EntityKey is temporary; otherwise, false.

When a new entity is created, the Entity Framework defines temporary key and sets the IsTemporary property to true. When you call the SaveChanges method, the Entity Framework assigns a permanent key and sets the IsTemporary property to false.


Temporary keys are constructed automatically by the framework; they cannot be constructed directly by a user.

Temporary keys have different comparison semantics than permanent keys:

  • Temporary keys use reference equality. That is, two references to the exact same temporary EntityKey instance are equal but no other EntityKey instances are equal.

  • Permanent keys determine equality based on the values of the contained key properties and the EntitySet. That is, you can have two separate EntityKey instances that are equal if their entity sets are the same and their key values are equal.

In addition, temporary keys have no EntitySet or key values, but permanent keys do.

When the AcceptChanges method is called on an entity's ObjectStateEntry and the entity transitions from the Added state to Unchanged state, the Entity Framework automatically computes a new permanent key for the entity and synchronizes all temporary key references.

.NET Framework

Supported in: 4, 3.5 SP1

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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