ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity) Class

Provides a simple API for configuring a one-to-many relationship.

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

Syntax

Declaration

public class ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> : ReferenceCollectionBuilder, IInfrastructure<IMutableModel>, IInfrastructure<InternalRelationshipBuilder> where TPrincipalEntity : class where TDependentEntity : classPublic Class ReferenceCollectionBuilder(Of TPrincipalEntity As Class, TDependentEntity As Class)
    Inherits ReferenceCollectionBuilder
    Implements IInfrastructure(Of IMutableModel), IInfrastructure(Of InternalRelationshipBuilder)

Type Parameters

TPrincipalEntity The principal entity type in this relationship.
TDependentEntity The dependent entity type in this relationship.

Inheritance Hierarchy

Inherited Members

Builder,
Builder,
Metadata,
Metadata,
IInfrastructure<IMutableModel>.Instance,
Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.IMutableModel>.Instance,
IInfrastructure<InternalRelationshipBuilder>.Instance,
Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalRelationshipBuilder>.Instance,
HasForeignKeyBuilder(IReadOnlyList<String>),
HasForeignKeyBuilder(IReadOnlyList(Of String)),
HasForeignKeyBuilder(IReadOnlyList<PropertyInfo>),
HasForeignKeyBuilder(IReadOnlyList(Of PropertyInfo)),
HasPrincipalKeyBuilder(IReadOnlyList<String>),
HasPrincipalKeyBuilder(IReadOnlyList(Of String)),
HasPrincipalKeyBuilder(IReadOnlyList<PropertyInfo>),
HasPrincipalKeyBuilder(IReadOnlyList(Of PropertyInfo)),
ToString(),
ToString(),
Equals(Object),
Equals(Object),
Equals(Object, Object),
Equals(Object, Object),
ReferenceEquals(Object, Object),
ReferenceEquals(Object, Object),
GetHashCode(),
GetHashCode(),
GetType(),
GetType(),
MemberwiseClone()
MemberwiseClone()

Constructors summary

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

Methods summary

Adds or updates an annotation on the relationship. If an annotation with the key specified in annotation already exists it's value will be updated.

Configures the property(s) to use as the foreign key for this relationship.

If HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>) is not specified, then an attempt will be made to match the data type and order of foreign key properties against the primary key of the principal entity type. If they do not match, new shadow state properties that form a unique index will be added to the principal entity type to serve as the reference key. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

Configures the property(s) to use as the foreign key for this relationship.

If the specified property name(s) do not exist on the entity type then a new shadow state property(s) will be added to serve as the foreign key. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

If HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>) is not specified, then an attempt will be made to match the data type and order of foreign key properties against the primary key of the principal entity type. If they do not match, new shadow state properties that form a unique index will be added to the principal entity type to serve as the reference key.

Configures the unique property(s) that this relationship targets. Typically you would only call this method if you want to use a property(s) other than the primary key as the principal property(s). If the specified property(s) is not already a unique constraint (or the primary key) then a new unique constraint will be introduced.

Configures the unique property(s) that this relationship targets. Typically you would only call this method if you want to use a property(s) other than the primary key as the principal property(s). If the specified property(s) is not already a unique constraint (or the primary key) then a new unique constraint will be introduced.

Configures whether this is a required relationship (i.e. whether the foreign key property(s) can be assigned null).

Configures how a delete operation is applied to dependent entities in the relationship when the principal is deleted or the relationship is severed.

Constructors

  • ReferenceCollectionBuilder(EntityType, EntityType, InternalRelationshipBuilder)
    ReferenceCollectionBuilder(EntityType, EntityType, InternalRelationshipBuilder)

    This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

    public ReferenceCollectionBuilder(EntityType principalEntityType, EntityType dependentEntityType, InternalRelationshipBuilder builder)Public Sub New(principalEntityType As EntityType, dependentEntityType As EntityType, builder As InternalRelationshipBuilder)

    Parameters

  • ReferenceCollectionBuilder(InternalRelationshipBuilder, ReferenceCollectionBuilder, Boolean, Boolean, Boolean)
    ReferenceCollectionBuilder(InternalRelationshipBuilder, ReferenceCollectionBuilder, Boolean, Boolean, Boolean)

    This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

    protected ReferenceCollectionBuilder(InternalRelationshipBuilder builder, ReferenceCollectionBuilder oldBuilder, bool foreignKeySet = false, bool principalKeySet = false, bool requiredSet = false)Protected Sub New(builder As InternalRelationshipBuilder, oldBuilder As ReferenceCollectionBuilder, foreignKeySet As Boolean = False, principalKeySet As Boolean = False, requiredSet As Boolean = False)

    Parameters

Methods

  • HasAnnotation(String, Object)
    HasAnnotation(String, Object)

    Adds or updates an annotation on the relationship. If an annotation with the key specified in annotation already exists it's value will be updated.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> HasAnnotation(string annotation, object value)Public Overridable Function HasAnnotation(annotation As String, value As Object) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • annotation
      System.String
      System.String

      The key of the annotation to be added or updated.

    • value
      System.Object
      System.Object

      The value to be stored in the annotation.

    Returns

  • HasForeignKey(Expression<Func<TDependentEntity, Object>>)
    HasForeignKey(Expression(Of Func(Of TDependentEntity, Object)))

    Configures the property(s) to use as the foreign key for this relationship.

    If HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>) is not specified, then an attempt will be made to match the data type and order of foreign key properties against the primary key of the principal entity type. If they do not match, new shadow state properties that form a unique index will be added to the principal entity type to serve as the reference key. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> HasForeignKey(Expression<Func<TDependentEntity, object>> foreignKeyExpression)Public Overridable Function HasForeignKey(foreignKeyExpression As Expression(Of Func(Of TDependentEntity, Object))) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • foreignKeyExpression
      System.Linq.Expressions.Expression<TDelegate><System.Func<T, TResult><TDependentEntity, System.Object>>
      System.Linq.Expressions.Expression<TDelegate>(Of System.Func<T, TResult>(Of TDependentEntity, System.Object))

      A lambda expression representing the foreign key property(s) (post => post.BlogId).

      If the foreign key is made up of multiple properties then specify an anonymous type including the properties (comment => new { comment.BlogId, comment.PostTitle }). The order specified should match the order of corresponding keys in HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>).

    Returns

  • HasForeignKey(String[])
    HasForeignKey(String())

    Configures the property(s) to use as the foreign key for this relationship.

    If the specified property name(s) do not exist on the entity type then a new shadow state property(s) will be added to serve as the foreign key. A shadow state property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

    If HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>) is not specified, then an attempt will be made to match the data type and order of foreign key properties against the primary key of the principal entity type. If they do not match, new shadow state properties that form a unique index will be added to the principal entity type to serve as the reference key.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> HasForeignKey(params string[] foreignKeyPropertyNames)Public Overridable Function HasForeignKey(ParamArray foreignKeyPropertyNames As String()) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • foreignKeyPropertyNames
      System.String[]
      System.String()

      The name(s) of the foreign key property(s).

    Returns

  • HasPrincipalKey(Expression<Func<TPrincipalEntity, Object>>)
    HasPrincipalKey(Expression(Of Func(Of TPrincipalEntity, Object)))

    Configures the unique property(s) that this relationship targets. Typically you would only call this method if you want to use a property(s) other than the primary key as the principal property(s). If the specified property(s) is not already a unique constraint (or the primary key) then a new unique constraint will be introduced.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> HasPrincipalKey(Expression<Func<TPrincipalEntity, object>> keyExpression)Public Overridable Function HasPrincipalKey(keyExpression As Expression(Of Func(Of TPrincipalEntity, Object))) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • keyExpression
      System.Linq.Expressions.Expression<TDelegate><System.Func<T, TResult><TPrincipalEntity, System.Object>>
      System.Linq.Expressions.Expression<TDelegate>(Of System.Func<T, TResult>(Of TPrincipalEntity, System.Object))

      A lambda expression representing the reference key property(s) (blog => blog.BlogId).

      If the principal key is made up of multiple properties then specify an anonymous type including the properties (post => new { post.BlogId, post.PostTitle }).

    Returns

  • HasPrincipalKey(String[])
    HasPrincipalKey(String())

    Configures the unique property(s) that this relationship targets. Typically you would only call this method if you want to use a property(s) other than the primary key as the principal property(s). If the specified property(s) is not already a unique constraint (or the primary key) then a new unique constraint will be introduced.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> HasPrincipalKey(params string[] keyPropertyNames)Public Overridable Function HasPrincipalKey(ParamArray keyPropertyNames As String()) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • keyPropertyNames
      System.String[]
      System.String()

      The name(s) of the reference key property(s).

    Returns

  • IsRequired(Boolean)
    IsRequired(Boolean)

    Configures whether this is a required relationship (i.e. whether the foreign key property(s) can be assigned null).

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> IsRequired(bool required = true)Public Overridable Function IsRequired(required As Boolean = True) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    • required
      System.Boolean
      System.Boolean

      A value indicating whether this is a required relationship.

    Returns

  • OnDelete(DeleteBehavior)
    OnDelete(DeleteBehavior)

    Configures how a delete operation is applied to dependent entities in the relationship when the principal is deleted or the relationship is severed.

    public virtual ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> OnDelete(DeleteBehavior deleteBehavior)Public Overridable Function OnDelete(deleteBehavior As DeleteBehavior) As ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

    Parameters

    Returns

Details

Assembly

Microsoft.EntityFrameworkCore.dll