語言

ReferenceOwnershipBuilder<TEntity,TRelatedEntity>.HasPrincipalKey 方法

定義

多載

名稱 Description
HasPrincipalKey(String[])

配置此關係所針對的獨特屬性。 通常只有當你想使用主鍵以外的屬性作為主要屬性時,才會呼叫此方法。 若指定的屬性尚未是唯一限制(或主鍵),則會引入新的唯一限制。

HasPrincipalKey(Expression<Func<TEntity,Object>>)

配置此關係所針對的獨特屬性。 通常只有當你想使用主鍵以外的屬性作為主要屬性時,才會呼叫此方法。 若指定的屬性尚未是唯一限制(或主鍵),則會引入新的唯一限制。

HasPrincipalKey(String[])

來源:
ReferenceOwnershipBuilder`.cs
來源:
ReferenceOwnershipBuilder`.cs

配置此關係所針對的獨特屬性。 通常只有當你想使用主鍵以外的屬性作為主要屬性時,才會呼叫此方法。 若指定的屬性尚未是唯一限制(或主鍵),則會引入新的唯一限制。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceOwnershipBuilder<TEntity,TRelatedEntity> HasPrincipalKey(params string[] keyPropertyNames);
override this.HasPrincipalKey : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceOwnershipBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)>
Public Overridable Function HasPrincipalKey (ParamArray keyPropertyNames As String()) As ReferenceOwnershipBuilder(Of TEntity, TRelatedEntity)

參數

keyPropertyNames
String[]

參考金鑰屬性的名稱。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

若指定多個主鍵屬性,主鍵屬性的順序應與主鍵或唯一約束屬性在主實體類型上配置的順序相符。

適用於

HasPrincipalKey(Expression<Func<TEntity,Object>>)

來源:
ReferenceOwnershipBuilder`.cs
來源:
ReferenceOwnershipBuilder`.cs

配置此關係所針對的獨特屬性。 通常只有當你想使用主鍵以外的屬性作為主要屬性時,才會呼叫此方法。 若指定的屬性尚未是唯一限制(或主鍵),則會引入新的唯一限制。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceOwnershipBuilder<TEntity,TRelatedEntity> HasPrincipalKey(System.Linq.Expressions.Expression<Func<TEntity,object>> keyExpression);
override this.HasPrincipalKey : System.Linq.Expressions.Expression<Func<'Entity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceOwnershipBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)>
Public Overridable Function HasPrincipalKey (keyExpression As Expression(Of Func(Of TEntity, Object))) As ReferenceOwnershipBuilder(Of TEntity, TRelatedEntity)

參數

keyExpression
Expression<Func<TEntity,Object>>

一個代表參考鍵屬性(t => t.Ids)的 lambda 表達式()。

若主鍵由多個屬性組成,則指定包含屬性(t => new { t.Id1, t.Id2 })的匿名型別。 指定的順序應與中 HasForeignKey(Expression<Func<TRelatedEntity,Object>>)對應屬性的順序相符。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

若指定多個主鍵屬性,主鍵屬性的順序應與主鍵或唯一約束屬性在主實體類型上配置的順序相符。

適用於