OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>.HasKey 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
HasKey(Expression<Func<TDependentEntity,Object>>) |
設定組成這個擁有之實體類型之主鍵的屬性。 |
HasKey(String[]) |
設定組成這個擁有之實體類型之主鍵的屬性。 |
HasKey(Expression<Func<TDependentEntity,Object>>)
設定組成這個擁有之實體類型之主鍵的屬性。
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)
參數
- keyExpression
- Expression<Func<TDependentEntity,Object>>
lambda 運算式,表示主鍵屬性 () (blog => blog.Url
) 。
如果主鍵是由多個屬性所組成,請指定匿名型別,包括屬性 (post => new { post.Title, post.BlogId }
) 。
傳回
KeyBuilder<TDependentEntity>
物件,可用來設定主鍵。
適用於
HasKey(String[])
設定組成這個擁有之實體類型之主鍵的屬性。
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)
參數
- propertyNames
- String[]
組成主鍵的屬性名稱。
傳回
KeyBuilder<TDependentEntity>
物件,可用來設定主鍵。