Share via


DependentNavigationPropertyConfiguration<TDependentEntityType>.HasForeignKey<TKey> Method

Definition

Configures the relationship to use foreign key property(s) that are exposed in the object model. If the foreign key property(s) are not exposed in the object model then use the Map method.

[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

Type Parameters

TKey

The type of the key.

Parameters

foreignKeyExpression
Expression<Func<TDependentEntityType,TKey>>

A lambda expression representing the property to be used as the foreign key. If the foreign key is made up of multiple properties then specify an anonymous type including the properties. When using multiple foreign key properties, the properties must be specified in the same order that the the primary key properties were configured for the principal entity type.

Returns

A configuration object that can be used to further configure the relationship.

Attributes

Applies to