Interface IForeignKey
- Namespace
- Microsoft.EntityFrameworkCore.Metadata
- Assembly
- Microsoft.EntityFrameworkCore.dll
Represents a relationship where a foreign key composed of properties on the dependent entity type references a corresponding primary or alternate key on the principal entity type.
public interface IForeignKey : IReadOnlyForeignKey, IAnnotatable, IReadOnlyAnnotatable
- Inherited Members
- Extension Methods
Remarks
See Modeling entity types and relationships for more information and examples.
Properties
DeclaringEntityType
Gets the dependent entity type. This may be different from the type that Properties are defined on when the relationship is defined a derived type in an inheritance hierarchy (since the properties may be defined on a base type).
IEntityType DeclaringEntityType { get; }
Property Value
DependentToPrincipal
Gets the navigation property on the dependent entity type that points to the principal entity.
INavigation? DependentToPrincipal { get; }
Property Value
PrincipalEntityType
Gets the principal entity type that this 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).
IEntityType PrincipalEntityType { get; }
Property Value
PrincipalKey
Gets the primary or alternate key that the relationship targets.
IKey PrincipalKey { get; }
Property Value
PrincipalToDependent
Gets the navigation property on the principal entity type that points to the dependent entity.
INavigation? PrincipalToDependent { get; }
Property Value
Properties
Gets the foreign key properties in the dependent entity.
IReadOnlyList<IProperty> Properties { get; }
Property Value
Methods
GetDependentKeyValueFactory()
Creates a factory for key values based on the foreign key values taken from various forms of entity data.
This method is typically used by database providers (and other extensions). It is generally not used in application code.
IDependentKeyValueFactory GetDependentKeyValueFactory()
Returns
- IDependentKeyValueFactory
The factory.
GetDependentKeyValueFactory<TKey>()
Creates a factory for key values based on the foreign key values taken from various forms of entity data.
This method is typically used by database providers (and other extensions). It is generally not used in application code.
IDependentKeyValueFactory<TKey> GetDependentKeyValueFactory<TKey>()
Returns
- IDependentKeyValueFactory<TKey>
The factory.
Type Parameters
TKey
The type of key instances.
GetNavigation(bool)
Returns a navigation associated with this foreign key.
INavigation? GetNavigation(bool pointsToPrincipal)
Parameters
pointsToPrincipal
boolA value indicating whether the navigation is on the dependent type pointing to the principal type.
Returns
- INavigation
A navigation associated with this foreign key or null.
GetReferencingSkipNavigations()
Gets all skip navigations using this foreign key.
IEnumerable<ISkipNavigation> GetReferencingSkipNavigations()
Returns
- IEnumerable<ISkipNavigation>
The skip navigations using this foreign key.
GetRelatedEntityType(IReadOnlyEntityType)
Gets the entity type related to the given one.
IEntityType GetRelatedEntityType(IReadOnlyEntityType entityType)
Parameters
entityType
IReadOnlyEntityTypeOne of the entity types related by the foreign key.
Returns
- IEntityType
The entity type related to the given one.