共用方式為


DependentNavigationPropertyConfiguration<TDependentEntityType>.HasForeignKey<TKey> 方法

定義

設定關聯性使用外部索引鍵屬性,這些屬性會在物件模型中公開。 如果外部索引鍵屬性不會在物件模型中公開,則使用 Map 方法。

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public System.Data.Entity.ModelConfiguration.Configuration.CascadableNavigationPropertyConfiguration HasForeignKey<TKey> (System.Linq.Expressions.Expression<Func<TDependentEntityType,TKey>> foreignKeyExpression);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public System.Data.Entity.ModelConfiguration.Configuration.CascadableNavigationPropertyConfiguration HasForeignKey<TKey> (System.Linq.Expressions.Expression<Func<TDependentEntityType,TKey>> foreignKeyExpression);
member this.HasForeignKey : System.Linq.Expressions.Expression<Func<'DependentEntityType, 'Key>> -> System.Data.Entity.ModelConfiguration.Configuration.CascadableNavigationPropertyConfiguration
Public Function HasForeignKey(Of TKey) (foreignKeyExpression As Expression(Of Func(Of TDependentEntityType, TKey))) As CascadableNavigationPropertyConfiguration

類型參數

TKey

索引鍵的類型。

參數

foreignKeyExpression
Expression<Func<TDependentEntityType,TKey>>

Lambda 運算式,表示要當做外部索引鍵使用的屬性。 如果外部索引鍵是由多個屬性所組成,則指定匿名型別 (包括屬性)。 使用多個外鍵屬性時,屬性的順序必須與主體實體類型設定主鍵屬性的順序相同。

傳回

可用來進一步設定關係的設定物件。

屬性

適用於