OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>.HasKey Method

Definition

Overloads

HasKey(Expression<Func<TDependentEntity,Object>>)

Sets the properties that make up the primary key for this owned entity type.

HasKey(String[])

Sets the properties that make up the primary key for this owned entity type.

HasKey(Expression<Func<TDependentEntity,Object>>)

Sets the properties that make up the primary key for this owned entity type.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder HasKey (System.Linq.Expressions.Expression<Func<TDependentEntity,object>> keyExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey (System.Linq.Expressions.Expression<Func<TDependentEntity,object>> keyExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey (System.Linq.Expressions.Expression<Func<TDependentEntity,object?>> keyExpression);
override this.HasKey : System.Linq.Expressions.Expression<Func<'DependentEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder
override this.HasKey : System.Linq.Expressions.Expression<Func<'DependentEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<'DependentEntity (requires 'DependentEntity : null)>
Public Overridable Function HasKey (keyExpression As Expression(Of Func(Of TDependentEntity, Object))) As KeyBuilder
Public Overridable Function HasKey (keyExpression As Expression(Of Func(Of TDependentEntity, Object))) As KeyBuilder(Of TDependentEntity)

Parameters

keyExpression
Expression<Func<TDependentEntity,Object>>

A lambda expression representing the primary key property(s) (blog => blog.Url).

If the primary key is made up of multiple properties then specify an anonymous type including the properties (post => new { post.Title, post.BlogId }).

Returns

KeyBuilder<TDependentEntity>

An object that can be used to configure the primary key.

Applies to

HasKey(String[])

Sets the properties that make up the primary key for this owned entity type.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<TDependentEntity> HasKey (params string[] propertyNames);
override this.HasKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder<'DependentEntity (requires 'DependentEntity : null)>
Public Overridable Function HasKey (ParamArray propertyNames As String()) As KeyBuilder(Of TDependentEntity)

Parameters

propertyNames
String[]

The names of the properties that make up the primary key.

Returns

KeyBuilder<TDependentEntity>

An object that can be used to configure the primary key.

Applies to