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

Definition

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.

public class ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> : ReferenceCollectionBuilder, IInfrastructure<IMutableModel>, IInfrastructure<InternalRelationshipBuilder> where TPrincipalEntity : class where TDependentEntity : class
Public 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
System.ObjectSystem.Object
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity>ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)
Implements

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
principalEntityType
EntityType EntityType
dependentEntityType
EntityType EntityType

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
foreignKeySet
System.Boolean System.Boolean
principalKeySet
System.Boolean System.Boolean
requiredSet
System.Boolean System.Boolean

Methods

Equals(Object) Equals(Object)

Inherited from System.Object

Equals(Object, Object) Equals(Object, Object)

Inherited from System.Object

GetHashCode() GetHashCode()

Inherited from System.Object

GetType() GetType()

Inherited from System.Object

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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

HasForeignKey(Expression<>>) 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<System.Func<TDependentEntity, System.Object>> System.Linq.Expressions.Expression(Of System.Func(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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

HasForeignKeyBuilder(IReadOnlyList) HasForeignKeyBuilder(IReadOnlyList(Of PropertyInfo))

HasForeignKeyBuilder(IReadOnlyList) HasForeignKeyBuilder(IReadOnlyList(Of String))

HasPrincipalKey(Expression<>>) 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<System.Func<TPrincipalEntity, System.Object>> System.Linq.Expressions.Expression(Of System.Func(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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

HasPrincipalKeyBuilder(IReadOnlyList) HasPrincipalKeyBuilder(IReadOnlyList(Of PropertyInfo))

HasPrincipalKeyBuilder(IReadOnlyList) HasPrincipalKeyBuilder(IReadOnlyList(Of String))

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
ReferenceCollectionBuilder<TPrincipalEntity, TDependentEntity> ReferenceCollectionBuilder(Of TPrincipalEntity, TDependentEntity)

The same builder instance so that multiple configuration calls can be chained.

MemberwiseClone() MemberwiseClone()

Inherited from System.Object

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
deleteBehavior
DeleteBehavior DeleteBehavior

The action to perform.

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

The same builder instance so that multiple configuration calls can be chained.

ReferenceEquals(Object, Object) ReferenceEquals(Object, Object)

Inherited from System.Object

ToString() ToString()

Inherited from System.Object

Properties

Builder Builder

IInfrastructure.Instance Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.Instance

IInfrastructure.Instance Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.Instance

Metadata Metadata