ObjectContext.CreateEntityKey Method (String, Object)

 

Creates the entity key for a specific object, or returns the entity key if it already exists.

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

public virtual EntityKey CreateEntityKey(
	string entitySetName,
	object entity
)

Parameters

entitySetName
Type: System.String

The fully qualified name of the entity set to which the entity object belongs.

entity
Type: System.Object

The object for which the entity key is being retrieved.

Return Value

Type: System.Data.Entity.Core.EntityKey

The EntityKey of the object.

Exception Condition
ArgumentNullException

When either parameter is null.

ArgumentException

When entitySetName is empty or when the type of the entity object does not exist in the entity set or when the entitySetName is not fully qualified.

InvalidOperationException

When the entity key cannot be constructed successfully based on the supplied parameters.