Share via


CollectionOwnershipBuilder Class

Definition

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

public class CollectionOwnershipBuilder : Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilderBase, Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder>
type CollectionOwnershipBuilder = class
    inherit ReferenceCollectionBuilderBase
    interface IInfrastructure<InternalEntityTypeBuilder>
Public Class CollectionOwnershipBuilder
Inherits ReferenceCollectionBuilderBase
Implements IInfrastructure(Of InternalEntityTypeBuilder)
Inheritance
CollectionOwnershipBuilder
Derived
Implements
IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalEntityTypeBuilder>

Constructors

CollectionOwnershipBuilder(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.

CollectionOwnershipBuilder(InternalRelationshipBuilder, CollectionOwnershipBuilder, 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.

Properties

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 ReferenceCollectionBuilderBase)
DependentEntityType

Gets the dependent entity type used to configure this relationship.

(Inherited from ReferenceCollectionBuilderBase)
Metadata

The foreign key that represents this relationship.

(Inherited from ReferenceCollectionBuilderBase)
OwnedEntityType

The owned entity type being configured.

PrincipalEntityType

Gets the principal entity type used to configure this relationship.

(Inherited from ReferenceCollectionBuilderBase)

Methods

FindRelatedEntityType(String, 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.

FindRelatedEntityType(Type, 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.

HasChangeTrackingStrategy(ChangeTrackingStrategy)

Configures the ChangeTrackingStrategy to be used for this entity type. This strategy indicates how the context detects changes to properties for an instance of the entity type.

HasData(Object[])

Configures this entity to have seed data. It is used to generate data motion migrations.

HasEntityTypeAnnotation(String, Object)

Adds or updates an annotation on the owned entity type. If an annotation with the key specified in annotation already exists its value will be updated.

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.

HasForeignKeyAnnotation(String, Object)

Adds or updates an annotation on the foreign key. If an annotation with the key specified in annotation already exists its value will be updated.

HasIndex(String[])

Configures an index on the specified properties. If there is an existing index on the given set of properties, then the existing index will be returned for configuration.

HasKey(String[])

Sets the properties that make up the primary key for this owned entity type.

HasOne(String, String)

Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.

Note that calling this method with no parameters will explicitly configure this side of the relationship to use no navigation property, even if such a property exists on the entity type. If the navigation property is to be used, then it must be specified.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasOne(Type, String)

Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.

Note that calling this method with no parameters will explicitly configure this side of the relationship to use no navigation property, even if such a property exists on the entity type. If the navigation property is to be used, then it must be specified.

After calling this method, you should chain a call to WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

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.

Ignore(String)

Excludes the given property from the entity type. This method is typically used to remove properties from the owned entity type that were added by convention.

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.

OwnsMany(String, String)

Configures a relationship where the target entity is owned by (or part of) this entity.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

OwnsMany(String, String, Action<CollectionOwnershipBuilder>)

Configures a relationship where this entity type provides identity to the other type in the relationship.

OwnsMany(Type, String)

Configures a relationship where the target entity is owned by (or part of) this entity.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

OwnsMany(Type, String, Action<CollectionOwnershipBuilder>)

Configures a relationship where this entity type provides identity to the other type in the relationship.

OwnsOne(String, String)

Configures a relationship where the target entity is owned by (or part of) this entity. The target entity key value is always propagated from the entity it belongs to.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

OwnsOne(String, String, Action<ReferenceOwnershipBuilder>)

Configures a relationship where the target entity is owned by (or part of) this entity. The target entity key value is always propagated from the entity it belongs to.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

OwnsOne(Type, String)

Configures a relationship where the target entity is owned by (or part of) this entity. The target entity key value is always propagated from the entity it belongs to.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

OwnsOne(Type, String, Action<ReferenceOwnershipBuilder>)

Configures a relationship where the target entity is owned by (or part of) this entity. The target entity key value is always propagated from the entity it belongs to.

The target entity type for each ownership relationship is treated as a different entity type even if the navigation is of the same type. Configuration of the target entity type isn't applied to the target entity type of other ownership relationships.

Most operations on an owned entity require accessing it through the owner entity using the corresponding navigation.

Property(String)

Returns an object that can be used to configure a property of the owned entity type. If no property with the given name exists, then a new property will be added.

When adding a new property with this overload the property name must match the name of a CLR property or field on the entity type. This overload cannot be used to add a new shadow state property.

Property(Type, String)

Returns an object that can be used to configure a property of the owned entity type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the entity class then it will be added to the model. If no property exists in the entity class, then a new shadow state property will be added. 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.

Property<TProperty>(String)

Returns an object that can be used to configure a property of the owned entity type. If no property with the given name exists, then a new property will be added.

When adding a new property, if a property with the same name exists in the entity class then it will be added to the model. If no property exists in the entity class, then a new shadow state property will be added. 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.

UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for all properties of this entity type.

By default, the backing field, if one is found by convention or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. Calling this method will change that behavior for all properties of this entity type as described in the PropertyAccessMode enum.

Calling this method overrides for all properties of this entity type any access mode that was set on the model.

Explicit Interface Implementations

IInfrastructure<IMutableModel>.Instance

The model that this relationship belongs to.

(Inherited from ReferenceCollectionBuilderBase)
IInfrastructure<InternalEntityTypeBuilder>.Instance

Gets the internal builder being used to configure the owned entity type.

IInfrastructure<InternalRelationshipBuilder>.Instance

Gets the internal builder being used to configure this relationship.

(Inherited from ReferenceCollectionBuilderBase)

Extension Methods

GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

HasConstraintName(CollectionOwnershipBuilder, String)

Configures the foreign key constraint name for this relationship when targeting a relational database.

ToTable(CollectionOwnershipBuilder, String)

Configures the view or table that the entity maps to when targeting a relational database.

ToTable(CollectionOwnershipBuilder, String, String)

Configures the view or table that the entity maps to when targeting a relational database.

ForSqlServerIsMemoryOptimized(CollectionOwnershipBuilder, Boolean)

Configures the table that the entity maps to when targeting SQL Server as memory-optimized.

Applies to