Creates the entity key for a specific object, or returns the entity key if it already exists.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
- Type: System.String
The fully qualified name of the entity set to which the entity object belongs.
- Type: System.Object
The object for which the entity key is being retrieved.
When either parameter is a null reference (Nothing in Visual Basic).
When entitySetName is empty.
When the type of the entity object does not exist in the entity set.
When the entitySetName is not fully qualified.
When the entity key cannot be constructed successfully based on the supplied parameters.
If an EntityKey does not exist for the entity, the method creates a new key for it.
This method is used to determine whether an object that has the same EntityKey is already attached to the ObjectContext. If an object that has the same EntityKey is already attached, an exception is raised. Use the method to try to retrieve the EntityKey of the detached object before calling the Attach method.
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.