IConventionEntityType.AddForeignKey Method

Definition

Overloads

AddForeignKey(IConventionProperty, IConventionKey, IConventionEntityType, Boolean)

Adds a new relationship to this entity type.

AddForeignKey(IReadOnlyList<IConventionProperty>, IConventionKey, IConventionEntityType, Boolean, Boolean)

Adds a new relationship to this entity type.

AddForeignKey(IConventionProperty, IConventionKey, IConventionEntityType, Boolean)

Adds a new relationship to this entity type.

public virtual Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey? AddForeignKey (Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property, Microsoft.EntityFrameworkCore.Metadata.IConventionKey principalKey, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType principalEntityType, bool fromDataAnnotation = false);
abstract member AddForeignKey : Microsoft.EntityFrameworkCore.Metadata.IConventionProperty * Microsoft.EntityFrameworkCore.Metadata.IConventionKey * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey
override this.AddForeignKey : Microsoft.EntityFrameworkCore.Metadata.IConventionProperty * Microsoft.EntityFrameworkCore.Metadata.IConventionKey * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey
Public Overridable Function AddForeignKey (property As IConventionProperty, principalKey As IConventionKey, principalEntityType As IConventionEntityType, Optional fromDataAnnotation As Boolean = false) As IConventionForeignKey

Parameters

property
IConventionProperty

The property that the foreign key is defined on.

principalKey
IConventionKey

The primary or alternate key that is referenced.

principalEntityType
IConventionEntityType

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

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

The newly created foreign key.

Applies to

AddForeignKey(IReadOnlyList<IConventionProperty>, IConventionKey, IConventionEntityType, Boolean, Boolean)

Adds a new relationship to this entity type.

public Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey AddForeignKey (System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> properties, Microsoft.EntityFrameworkCore.Metadata.IConventionKey principalKey, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType principalEntityType, bool setComponentConfigurationSource = true, bool fromDataAnnotation = false);
public Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey? AddForeignKey (System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> properties, Microsoft.EntityFrameworkCore.Metadata.IConventionKey principalKey, Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType principalEntityType, bool setComponentConfigurationSource = true, bool fromDataAnnotation = false);
abstract member AddForeignKey : System.Collections.Generic.IReadOnlyList<Microsoft.EntityFrameworkCore.Metadata.IConventionProperty> * Microsoft.EntityFrameworkCore.Metadata.IConventionKey * Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * bool * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionForeignKey
Public Function AddForeignKey (properties As IReadOnlyList(Of IConventionProperty), principalKey As IConventionKey, principalEntityType As IConventionEntityType, Optional setComponentConfigurationSource As Boolean = true, Optional fromDataAnnotation As Boolean = false) As IConventionForeignKey

Parameters

properties
IReadOnlyList<IConventionProperty>

The properties that the foreign key is defined on.

principalKey
IConventionKey

The primary or alternate key that is referenced.

principalEntityType
IConventionEntityType

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

setComponentConfigurationSource
Boolean

Indicates whether the configuration source should be set for the properties, principal key and principal end.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

The newly created foreign key.

Applies to