EntityTypeExtensions.FindForeignKey Method

Definition

Gets the foreign key for the given properties that points to a given primary or alternate key. Returns null if no foreign key is found.

public static Microsoft.EntityFrameworkCore.Metadata.IForeignKey FindForeignKey (this Microsoft.EntityFrameworkCore.Metadata.IEntityType entityType, Microsoft.EntityFrameworkCore.Metadata.IProperty property, Microsoft.EntityFrameworkCore.Metadata.IKey principalKey, Microsoft.EntityFrameworkCore.Metadata.IEntityType principalEntityType);
static member FindForeignKey : Microsoft.EntityFrameworkCore.Metadata.IEntityType * Microsoft.EntityFrameworkCore.Metadata.IProperty * Microsoft.EntityFrameworkCore.Metadata.IKey * Microsoft.EntityFrameworkCore.Metadata.IEntityType -> Microsoft.EntityFrameworkCore.Metadata.IForeignKey
<Extension()>
Public Function FindForeignKey (entityType As IEntityType, property As IProperty, principalKey As IKey, principalEntityType As IEntityType) As IForeignKey

Parameters

entityType
IEntityType

The entity type.

property
IProperty

The property that the foreign key is defined on.

principalKey
IKey

The primary or alternate key that is referenced.

principalEntityType
IEntityType

The entity type that the relationship targets. This may be different from the type that principalKey is defined on when the relationship targets a derived type in an inheritance hierarchy (since the key is defined on the base type of the hierarchy).

Returns

The foreign key, or null if none is defined.

Applies to