ReferenceOwnershipBuilder<TEntity,TRelatedEntity>.HasKey Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Entity Framework