ReferenceCollectionBuilder ReferenceCollectionBuilder 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 : IInfrastructure<IMutableModel>, IInfrastructure<InternalRelationshipBuilder>
Public Class ReferenceCollectionBuilder
    Implements IInfrastructure(Of IMutableModel), IInfrastructure(Of InternalRelationshipBuilder)
Inheritance
System.ObjectSystem.Object
ReferenceCollectionBuilderReferenceCollectionBuilder
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

Properties

Builder Builder

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 virtual InternalRelationshipBuilder Builder { get; }
Protected Overridable ReadOnly Property Builder As InternalRelationshipBuilder

Metadata Metadata

The foreign key that represents this relationship.

public virtual IMutableForeignKey Metadata { get; }
Public Overridable ReadOnly Property Metadata As IMutableForeignKey

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 HasAnnotation(string annotation, object value)
Public Overridable Function HasAnnotation(annotation As String, value As Object) As ReferenceCollectionBuilder
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

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(String[]) 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 HasForeignKey(params string[] foreignKeyPropertyNames)
Public Overridable Function HasForeignKey(ParamArray foreignKeyPropertyNames As String()) As ReferenceCollectionBuilder
Parameters
foreignKeyPropertyNames
System.String[] System.String()

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

Returns

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

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

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 virtual InternalRelationshipBuilder HasForeignKeyBuilder(IReadOnlyList<PropertyInfo> foreignKeyProperties)
Protected Overridable Function HasForeignKeyBuilder(foreignKeyProperties As IReadOnlyList(Of PropertyInfo)) As InternalRelationshipBuilder
Parameters
foreignKeyProperties
System.Collections.Generic.IReadOnlyList<System.Reflection.PropertyInfo> System.Collections.Generic.IReadOnlyList(Of System.Reflection.PropertyInfo)
Returns

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

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 virtual InternalRelationshipBuilder HasForeignKeyBuilder(IReadOnlyList<string> foreignKeyPropertyNames)
Protected Overridable Function HasForeignKeyBuilder(foreignKeyPropertyNames As IReadOnlyList(Of String)) As InternalRelationshipBuilder
Parameters
foreignKeyPropertyNames
System.Collections.Generic.IReadOnlyList<System.String> System.Collections.Generic.IReadOnlyList(Of System.String)
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 HasPrincipalKey(params string[] keyPropertyNames)
Public Overridable Function HasPrincipalKey(ParamArray keyPropertyNames As String()) As ReferenceCollectionBuilder
Parameters
keyPropertyNames
System.String[] System.String()

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

Returns

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

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

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 virtual InternalRelationshipBuilder HasPrincipalKeyBuilder(IReadOnlyList<PropertyInfo> keyProperties)
Protected Overridable Function HasPrincipalKeyBuilder(keyProperties As IReadOnlyList(Of PropertyInfo)) As InternalRelationshipBuilder
Parameters
keyProperties
System.Collections.Generic.IReadOnlyList<System.Reflection.PropertyInfo> System.Collections.Generic.IReadOnlyList(Of System.Reflection.PropertyInfo)
Returns

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

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 virtual InternalRelationshipBuilder HasPrincipalKeyBuilder(IReadOnlyList<string> keyPropertyNames)
Protected Overridable Function HasPrincipalKeyBuilder(keyPropertyNames As IReadOnlyList(Of String)) As InternalRelationshipBuilder
Parameters
keyPropertyNames
System.Collections.Generic.IReadOnlyList<System.String> System.Collections.Generic.IReadOnlyList(Of System.String)
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 IsRequired(bool required = true)
Public Overridable Function IsRequired(required As Boolean = True) As ReferenceCollectionBuilder
Parameters
required
System.Boolean System.Boolean

A value indicating whether this is a required relationship.

Returns

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 OnDelete(DeleteBehavior deleteBehavior)
Public Overridable Function OnDelete(deleteBehavior As DeleteBehavior) As ReferenceCollectionBuilder
Parameters
deleteBehavior
DeleteBehavior DeleteBehavior

The action to perform.

Returns

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

Explicit Interface Implementations

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

The model that this relationship belongs to.

IMutableModel IInfrastructure<IMutableModel>.Instance { get; }
ReadOnly WriteOnly Property Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.IMutableModel>.Instance As IMutableModel Implements IInfrastructure(Of IMutableModel).Instance
Returns

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

Gets the internal builder being used to configure this relationship.

InternalRelationshipBuilder IInfrastructure<InternalRelationshipBuilder>.Instance { get; }
ReadOnly WriteOnly Property Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalRelationshipBuilder>.Instance As InternalRelationshipBuilder Implements IInfrastructure(Of InternalRelationshipBuilder).Instance
Returns