Interface IReadOnlyForeignKey
- 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 IReadOnlyForeignKey : 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).
IReadOnlyEntityType DeclaringEntityType { get; }
Property Value
DeleteBehavior
Gets a value indicating how a delete operation is applied to dependent entities in the relationship when the principal is deleted or the relationship is severed.
DeleteBehavior DeleteBehavior { get; }
Property Value
- DeleteBehavior
DependentToPrincipal
Gets the navigation property on the dependent entity type that points to the principal entity.
IReadOnlyNavigation? DependentToPrincipal { get; }
Property Value
IsOwnership
Gets a value indicating whether this relationship defines an ownership. If true, the dependent entity must always be accessed via the navigation from the principal entity.
bool IsOwnership { get; }
Property Value
IsRequired
Gets a value indicating whether the principal entity is required. If true, the dependent entity must always be assigned to a valid principal entity.
bool IsRequired { get; }
Property Value
IsRequiredDependent
Gets a value indicating whether the dependent entity is required. If true, the principal entity must always have a valid dependent entity assigned.
bool IsRequiredDependent { get; }
Property Value
IsUnique
Gets a value indicating whether the values assigned to the foreign key properties are unique.
bool IsUnique { 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).
IReadOnlyEntityType PrincipalEntityType { get; }
Property Value
PrincipalKey
Gets the primary or alternate key that the relationship targets.
IReadOnlyKey PrincipalKey { get; }
Property Value
PrincipalToDependent
Gets the navigation property on the principal entity type that points to the dependent entity.
IReadOnlyNavigation? PrincipalToDependent { get; }
Property Value
Properties
Gets the foreign key properties in the dependent entity.
IReadOnlyList<IReadOnlyProperty> Properties { get; }
Property Value
Methods
GetNavigation(bool)
Returns a navigation associated with this foreign key.
IReadOnlyNavigation? GetNavigation(bool pointsToPrincipal)
Parameters
pointsToPrincipal
boolA value indicating whether the navigation is on the dependent type pointing to the principal type.
Returns
- IReadOnlyNavigation
A navigation associated with this foreign key or null.
GetReferencingSkipNavigations()
Gets the skip navigations using this foreign key.
IEnumerable<IReadOnlySkipNavigation> GetReferencingSkipNavigations()
Returns
- IEnumerable<IReadOnlySkipNavigation>
The skip navigations using this foreign key.
GetRelatedEntityType(IReadOnlyEntityType)
Gets the entity type related to the given one.
IReadOnlyEntityType GetRelatedEntityType(IReadOnlyEntityType entityType)
Parameters
entityType
IReadOnlyEntityTypeOne of the entity types related by the foreign key.
Returns
- IReadOnlyEntityType
The entity type related to the given one.
IsBaseLinking()
Returns a value indicating whether the foreign key is defined on the primary key and pointing to the same primary key.
bool IsBaseLinking()
Returns
- bool
A value indicating whether the foreign key is defined on the primary key and pointing to the same primary key.
ToDebugString(MetadataDebugStringOptions, int)
Creates a human-readable representation of the given metadata.
Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.
string ToDebugString(MetadataDebugStringOptions options = MetadataDebugStringOptions.ShortDefault, int indent = 0)
Parameters
options
MetadataDebugStringOptionsOptions for generating the string.
indent
intThe number of indent spaces to use before each new line.
Returns
- string
A human-readable representation.