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)
- TPrincipalEntity
The principal entity type in this relationship.
- TDependentEntity
The dependent entity type in this relationship.
- Inheritance
-
System.ObjectSystem.ObjectReferenceCollectionBuilder<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)
- 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)
- foreignKeySet
- System.Boolean System.Boolean
- principalKeySet
- System.Boolean System.Boolean
- requiredSet
- System.Boolean System.Boolean
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)
- 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.
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)
- 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>>).
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)
- foreignKeyPropertyNames
- System.String[] System.String()
The name(s) of the foreign key property(s).
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.
(Inherited from ReferenceCollectionBuilder)
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.
(Inherited from ReferenceCollectionBuilder)
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)
- 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 }
).
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)
- keyPropertyNames
- System.String[] System.String()
The name(s) of the reference key property(s).
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.
(Inherited from ReferenceCollectionBuilder)
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.
(Inherited from ReferenceCollectionBuilder)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)
- required
- System.Boolean System.Boolean
A value indicating whether this is a required relationship.
The same builder instance so that multiple configuration calls can be chained.
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)
- deleteBehavior
- DeleteBehavior DeleteBehavior
The action to perform.
The same builder instance so that multiple configuration calls can be chained.
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.
(Inherited from ReferenceCollectionBuilder)
IInfrastructure.Instance
Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.Instance
The model that this relationship belongs to.
(Inherited from ReferenceCollectionBuilder)
IInfrastructure.Instance
Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure.Instance
Gets the internal builder being used to configure this relationship.
(Inherited from ReferenceCollectionBuilder)Metadata Metadata
The foreign key that represents this relationship.
(Inherited from ReferenceCollectionBuilder)