ReferenceOwnershipBuilder<TEntity,TRelatedEntity>.HasKey Method

Definition

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<TRelatedEntity,object>> keyExpression);
override this.HasKey : System.Linq.Expressions.Expression<Func<'RelatedEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.KeyBuilder
Public Overridable Function HasKey (keyExpression As Expression(Of Func(Of TRelatedEntity, Object))) As KeyBuilder

Parameters

keyExpression
Expression<Func<TRelatedEntity,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

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

Applies to