IConventionForeignKey Interface

Definition

Represents a relationship where a foreign key property(s) in a dependent entity type reference a corresponding primary or alternate key in a principal entity type.

public interface IConventionForeignKey : Microsoft.EntityFrameworkCore.Metadata.IConventionAnnotatable, Microsoft.EntityFrameworkCore.Metadata.IForeignKey
public interface IConventionForeignKey : Microsoft.EntityFrameworkCore.Metadata.IConventionAnnotatable, Microsoft.EntityFrameworkCore.Metadata.IReadOnlyForeignKey
type IConventionForeignKey = interface
    interface IForeignKey
    interface IAnnotatable
    interface IConventionAnnotatable
type IConventionForeignKey = interface
    interface IReadOnlyForeignKey
    interface IReadOnlyAnnotatable
    interface IConventionAnnotatable
Public Interface IConventionForeignKey
Implements IConventionAnnotatable, IForeignKey
Public Interface IConventionForeignKey
Implements IConventionAnnotatable, IReadOnlyForeignKey
Implements

Remarks

This interface is used during model creation and allows the metadata to be modified. Once the model is built, IForeignKey represents a read-only view of the same metadata.

See Model building conventions for more information and examples.

Properties

Builder

Gets the builder that can be used to configure this foreign key.

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).

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.

(Inherited from IReadOnlyForeignKey)
DependentToPrincipal

Gets the navigation property on the dependent entity type that points to the principal entity.

IsInModel

Indicates whether this object is in a model, i.e. hasn't been removed from one.

(Inherited from IConventionAnnotatable)
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.

(Inherited from IReadOnlyForeignKey)
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.

(Inherited from IReadOnlyForeignKey)
IsRequiredDependent

Gets a value indicating whether the dependent entity is required. If true, the principal entity must always have a valid dependent entity assigned.

(Inherited from IReadOnlyForeignKey)
IsUnique

Gets a value indicating whether the values assigned to the foreign key properties are unique.

(Inherited from IReadOnlyForeignKey)
Item[String]

Gets the value of the annotation with the given name, returning null if it does not exist.

(Inherited from IReadOnlyAnnotatable)
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).

PrincipalKey

Gets the primary or alternate key that the relationship targets.

PrincipalToDependent

Gets the navigation property on the principal entity type that points to the dependent entity.

Properties

Gets the foreign key properties in the dependent entity.

Methods

AddAnnotation(String, Object, Boolean)

Adds an annotation to this object. Throws if an annotation with the specified name already exists.

(Inherited from IConventionAnnotatable)
AddAnnotations(IEnumerable<IConventionAnnotation>, Boolean)

Adds annotations to an object.

(Inherited from IConventionAnnotatable)
AddRuntimeAnnotation(String, Object)

Adds a runtime annotation to this object. Throws if an annotation with the specified name already exists.

(Inherited from IAnnotatable)
AnnotationsToDebugString(Int32)

Gets the debug string for all annotations declared on the object.

(Inherited from IReadOnlyAnnotatable)
FindAnnotation(String)

Gets the annotation with the given name, returning null if it does not exist.

(Inherited from IReadOnlyAnnotatable)
FindRuntimeAnnotation(String)

Gets the runtime annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)
FindRuntimeAnnotationValue(String)

Gets the value of the runtime annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)
GetAnnotation(String)

Gets the annotation with the given name, throwing if it does not exist.

(Inherited from IReadOnlyAnnotatable)
GetAnnotations()

Gets all annotations on the current object.

(Inherited from IReadOnlyAnnotatable)
GetConfigurationSource()

Returns the configuration source for this property.

GetDeleteBehaviorConfigurationSource()

Returns the configuration source for DeleteBehavior.

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.

(Inherited from IForeignKey)
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.

(Inherited from IForeignKey)
GetDependentToPrincipalConfigurationSource()

Returns the configuration source for DependentToPrincipal.

GetIsOwnershipConfigurationSource()

Returns the configuration source for IsOwnership.

GetIsRequiredConfigurationSource()

Returns the configuration source for IsRequired.

GetIsRequiredDependentConfigurationSource()

Returns the configuration source for IsRequiredDependent.

GetIsUniqueConfigurationSource()

Returns the configuration source for IsUnique.

GetNavigation(Boolean)

Returns a navigation associated with this foreign key.

GetOrAddRuntimeAnnotationValue<TValue,TArg>(String, Func<TArg,TValue>, TArg)

Gets the value of the runtime annotation with the given name, adding it if one does not exist.

(Inherited from IAnnotatable)
GetPrincipalEndConfigurationSource()

Returns the configuration source for PrincipalEntityType.

GetPrincipalKeyConfigurationSource()

Returns the configuration source for PrincipalKey.

GetPrincipalToDependentConfigurationSource()

Returns the configuration source for PrincipalToDependent.

GetPropertiesConfigurationSource()

Returns the configuration source for Properties.

GetReferencingSkipNavigations()

Gets all skip navigations using this foreign key.

GetRelatedEntityType(IReadOnlyEntityType)

Gets the entity type related to the given one.

GetRuntimeAnnotations()

Gets all the runtime annotations on the current object.

(Inherited from IAnnotatable)
HasDependentToPrincipal(MemberInfo, Boolean)
Obsolete.

Sets the navigation property on the dependent entity type that points to the principal entity.

HasDependentToPrincipal(String, Boolean)
Obsolete.

Sets the navigation property on the dependent entity type that points to the principal entity.

HasPrincipalToDependent(MemberInfo, Boolean)
Obsolete.

Sets the navigation property on the principal entity type that points to the dependent entity.

HasPrincipalToDependent(String, Boolean)
Obsolete.

Sets the navigation property on the principal entity type that points to the dependent entity.

IsBaseLinking()

Returns a value indicating whether the foreign key is defined on the primary key and pointing to the same primary key.

(Inherited from IReadOnlyForeignKey)
RemoveAnnotation(String)

Removes the annotation with the given name from this object.

(Inherited from IConventionAnnotatable)
RemoveRuntimeAnnotation(String)

Removes the given runtime annotation from this object.

(Inherited from IAnnotatable)
SetAnnotation(String, Object, Boolean)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists.

(Inherited from IConventionAnnotatable)
SetDeleteBehavior(Nullable<DeleteBehavior>, Boolean)

Sets 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.

SetDependentToPrincipal(MemberInfo, Boolean)

Sets the navigation property on the dependent entity type that points to the principal entity.

SetDependentToPrincipal(String, Boolean)

Sets the navigation property on the dependent entity type that points to the principal entity.

SetIsOwnership(Nullable<Boolean>, Boolean)

Sets 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.

SetIsRequired(Nullable<Boolean>, Boolean)

Sets a value indicating whether the principal entity is required. If true, the dependent entity must always be assigned to a valid principal entity.

SetIsRequiredDependent(Nullable<Boolean>, Boolean)

Sets a value indicating whether the dependent entity is required. If true, the principal entity must always have a valid dependent entity assigned.

SetIsUnique(Nullable<Boolean>, Boolean)

Sets a value indicating whether the values assigned to the foreign key properties are unique.

SetOrRemoveAnnotation(String, Object, Boolean)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists. Removes the existing annotation if null is supplied.

(Inherited from IConventionAnnotatable)
SetPrincipalToDependent(MemberInfo, Boolean)

Sets the navigation property on the principal entity type that points to the dependent entity.

SetPrincipalToDependent(String, Boolean)

Sets the navigation property on the principal entity type that points to the dependent entity.

SetProperties(IReadOnlyList<IConventionProperty>, IConventionKey, Boolean)

Sets the foreign key properties and that target principal key.

SetRuntimeAnnotation(String, Object)

Sets the runtime annotation stored under the given key. Overwrites the existing annotation if an annotation with the specified name already exists.

(Inherited from IAnnotatable)
ToDebugString(MetadataDebugStringOptions, Int32)

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.

(Inherited from IReadOnlyForeignKey)

Extension Methods

AddAnnotations(IConventionAnnotatable, IEnumerable<IConventionAnnotation>, Boolean)

Adds annotations to an object.

GetAnnotation(IConventionAnnotatable, String)

Gets the annotation with the given name, throwing if it does not exist.

SetOrRemoveAnnotation(IConventionAnnotatable, String, Object, Boolean)

Sets the annotation stored under the given name. Overwrites the existing annotation if an annotation with the specified name already exists. Removes the existing annotation if null is supplied.

GetNavigation(IConventionForeignKey, Boolean)

Returns a navigation associated with this foreign key.

GetRelatedEntityType(IConventionForeignKey, IConventionEntityType)

Gets the entity type related to the given one.

GetDependentKeyValueFactory<TKey>(IForeignKey)

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.

GetNavigation(IForeignKey, Boolean)

Returns a navigation associated with this foreign key.

GetRelatedEntityType(IForeignKey, IEntityType)

Gets the entity type related to the given one.

IsBaseLinking(IForeignKey)

Returns a value indicating whether the foreign key is defined on the primary key and pointing to the same primary key.

ToDebugString(IForeignKey, MetadataDebugStringOptions, Int32)

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.

AnnotationsToDebugString(IAnnotatable, Int32)

Gets the debug string for all annotations declared on the object.

GetAnnotation(IAnnotatable, String)

Gets the annotation with the given name, throwing if it does not exist.

FindSharedObjectRootForeignKey(IConventionForeignKey, StoreObjectIdentifier)

Finds the first IConventionForeignKey that is mapped to the same constraint in a shared table-like object.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

FindSharedObjectRootForeignKey(IForeignKey, StoreObjectIdentifier)

Finds the first IConventionForeignKey that is mapped to the same constraint in a shared table-like object.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

FindSharedObjectRootForeignKey(IReadOnlyForeignKey, StoreObjectIdentifier)

Finds the first IForeignKey that is mapped to the same constraint in a shared table-like object.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

GetConstraintName(IForeignKey, StoreObjectIdentifier, StoreObjectIdentifier)

Returns the foreign key constraint name.

GetConstraintName(IForeignKey)

Returns the foreign key constraint name.

GetConstraintName(IReadOnlyForeignKey, StoreObjectIdentifier, StoreObjectIdentifier)

Returns the foreign key constraint name.

GetConstraintName(IReadOnlyForeignKey)

Returns the foreign key constraint name.

GetConstraintNameConfigurationSource(IConventionForeignKey)

Gets the ConfigurationSource for the constraint name.

GetDefaultName(IForeignKey, StoreObjectIdentifier, StoreObjectIdentifier)

Returns the default constraint name that would be used for this foreign key.

GetDefaultName(IForeignKey)

Returns the default constraint name that would be used for this foreign key.

GetDefaultName(IReadOnlyForeignKey, StoreObjectIdentifier, StoreObjectIdentifier)

Returns the default constraint name that would be used for this foreign key.

GetDefaultName(IReadOnlyForeignKey)

Returns the default constraint name that would be used for this foreign key.

GetMappedConstraints(IForeignKey)

Gets the foreign key constraints to which the foreign key is mapped.

IsRowInternal(IReadOnlyForeignKey, StoreObjectIdentifier)

Returns a value indicating whether this foreign key is between two entity types sharing the same table-like store object.

SetConstraintName(IConventionForeignKey, String, Boolean)

Sets the foreign key constraint name.

Applies to