DependentNavigationPropertyConfiguration<TDependentEntityType>.HasForeignKey<TKey> Method
[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]
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.
Namespace: System.Data.Entity.ModelConfiguration.Configuration
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")> _
Public Function HasForeignKey(Of TKey) ( _
foreignKeyExpression As Expression(Of Func(Of TDependentEntityType, TKey)) _
) As CascadableNavigationPropertyConfiguration
'Usage
Dim instance As DependentNavigationPropertyConfiguration
Dim foreignKeyExpression As Expression(Of Func(Of TDependentEntityType, TKey))
Dim returnValue As CascadableNavigationPropertyConfiguration
returnValue = instance.HasForeignKey(foreignKeyExpression)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public CascadableNavigationPropertyConfiguration HasForeignKey<TKey>(
Expression<Func<TDependentEntityType, TKey>> foreignKeyExpression
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1011:ConsiderPassingBaseTypesAsParameters")]
public:
generic<typename TKey>
CascadableNavigationPropertyConfiguration^ HasForeignKey(
Expression<Func<TDependentEntityType, TKey>^>^ foreignKeyExpression
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")>]
member HasForeignKey :
foreignKeyExpression:Expression<Func<'TDependentEntityType, 'TKey>> -> CascadableNavigationPropertyConfiguration
JScript does not support generic types and methods.
Type Parameters
- TKey
The type of the key.
Parameters
- foreignKeyExpression
Type: System.Linq.Expressions.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.
Return Value
Type: System.Data.Entity.ModelConfiguration.Configuration.CascadableNavigationPropertyConfiguration
A configuration object that can be used to further configure the relationship.
See Also
Reference
DependentNavigationPropertyConfiguration<TDependentEntityType> Class
System.Data.Entity.ModelConfiguration.Configuration Namespace