Share via


ObjectContext.CreateEntityKey(String, Object) Method

Definition

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

public virtual System.Data.Entity.Core.EntityKey CreateEntityKey (string entitySetName, object entity);
abstract member CreateEntityKey : string * obj -> System.Data.Entity.Core.EntityKey
override this.CreateEntityKey : string * obj -> System.Data.Entity.Core.EntityKey
Public Overridable Function CreateEntityKey (entitySetName As String, entity As Object) As EntityKey

Parameters

entitySetName
String

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

entity
Object

The object for which the entity key is being retrieved.

Returns

The EntityKey of the object.

Exceptions

When either parameter is null.

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.

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

Applies to