Share via


ReferenceOwnershipBuilder<TEntity,TRelatedEntity> Class

Definition

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

public class ReferenceOwnershipBuilder<TEntity,TRelatedEntity> : Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceOwnershipBuilder where TEntity : class where TRelatedEntity : class
type ReferenceOwnershipBuilder<'Entity, 'RelatedEntity (requires 'Entity : null and 'RelatedEntity : null)> = class
    inherit ReferenceOwnershipBuilder
Public Class ReferenceOwnershipBuilder(Of TEntity, TRelatedEntity)
Inherits ReferenceOwnershipBuilder

Type Parameters

TEntity
TRelatedEntity
Inheritance
ReferenceOwnershipBuilder<TEntity,TRelatedEntity>

Constructors

ReferenceOwnershipBuilder<TEntity,TRelatedEntity>(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.

ReferenceOwnershipBuilder<TEntity,TRelatedEntity>(InternalRelationshipBuilder, ReferenceOwnershipBuilder, Boolean, 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

Gets the internal builder being used to configure this relationship.

(Inherited from ReferenceReferenceBuilderBase)
DeclaringEntityType

Gets the first entity type used to configure this relationship.

(Inherited from ReferenceReferenceBuilderBase)
Metadata

The foreign key that represents this relationship.

(Inherited from ReferenceReferenceBuilderBase)
OwnedEntityType

The owned entity type being configured.

(Inherited from ReferenceOwnershipBuilder)
RelatedEntityType

Gets the second entity type used to configure this relationship.

(Inherited from ReferenceReferenceBuilderBase)

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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
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.

HasData(Object[])

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

(Inherited from ReferenceOwnershipBuilder)
HasData(TRelatedEntity[])

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(Expression<Func<TRelatedEntity,Object>>)

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<TEntity,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.

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(Expression<Func<TRelatedEntity,Object>>)

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.

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.

(Inherited from ReferenceOwnershipBuilder)
HasKey(Expression<Func<TRelatedEntity,Object>>)

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

HasKey(String[])

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

(Inherited from ReferenceOwnershipBuilder)
HasMany(String, String)

Configures a relationship where this entity type has a collection that contains instances 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 WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from ReferenceOwnershipBuilder)
HasMany(Type, String)

Configures a relationship where this entity type has a collection that contains instances 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 WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

(Inherited from ReferenceOwnershipBuilder)
HasMany<TNewRelatedEntity>(Expression<Func<TRelatedEntity,IEnumerable<TNewRelatedEntity>>>)

Configures a relationship where this entity type has a collection that contains instances 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 WithOne(Expression<Func<TRelatedEntity,TEntity>>) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
HasOne<TNewRelatedEntity>(Expression<Func<TRelatedEntity,TNewRelatedEntity>>)

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(Expression<Func<TRelatedEntity,IEnumerable<TEntity>>>) or WithOne(Expression<Func<TRelatedEntity,TEntity>>) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.

HasOne<TNewRelatedEntity>(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(Expression<Func<TEntity,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.

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(Expression<Func<TRelatedEntity,Object>>)

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.

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, Action<CollectionOwnershipBuilder>)

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

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
OwnsMany(Type, String, Action<CollectionOwnershipBuilder>)

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

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
OwnsMany<TDependentEntity>(Expression<Func<TRelatedEntity,IEnumerable<TDependentEntity>>>, Action<CollectionOwnershipBuilder<TRelatedEntity,TDependentEntity>>)

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<TDependentEntity>(Expression<Func<TRelatedEntity,IEnumerable<TDependentEntity>>>)

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<TDependentEntity>(String, Action<CollectionOwnershipBuilder<TRelatedEntity,TDependentEntity>>)

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

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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
OwnsOne<TNewRelatedEntity>(Expression<Func<TRelatedEntity,TNewRelatedEntity>>, Action<ReferenceOwnershipBuilder<TRelatedEntity,TNewRelatedEntity>>)

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<TNewRelatedEntity>(Expression<Func<TRelatedEntity,TNewRelatedEntity>>)

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<TNewRelatedEntity>(String, Action<ReferenceOwnershipBuilder<TRelatedEntity,TNewRelatedEntity>>)

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

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.

(Inherited from ReferenceOwnershipBuilder)
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.

(Inherited from ReferenceOwnershipBuilder)
Property<TProperty>(Expression<Func<TRelatedEntity,TProperty>>)

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.

(Inherited from ReferenceOwnershipBuilder)
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 ReferenceReferenceBuilderBase)
IInfrastructure<InternalEntityTypeBuilder>.Instance

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

(Inherited from ReferenceOwnershipBuilder)
IInfrastructure<InternalRelationshipBuilder>.Instance

Gets the internal builder being used to configure this relationship.

(Inherited from ReferenceReferenceBuilderBase)

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(ReferenceOwnershipBuilder, String)

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

HasConstraintName<TEntity,TRelatedEntity>(ReferenceOwnershipBuilder<TEntity,TRelatedEntity>, String)

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

ToTable(ReferenceOwnershipBuilder, String, String)

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

ToTable(ReferenceOwnershipBuilder, String)

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

ToTable<TEntity,TRelatedEntity>(ReferenceOwnershipBuilder<TEntity,TRelatedEntity>, String, String)

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

ToTable<TEntity,TRelatedEntity>(ReferenceOwnershipBuilder<TEntity,TRelatedEntity>, String)

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

ForSqlServerIsMemoryOptimized(ReferenceOwnershipBuilder, Boolean)

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

ForSqlServerIsMemoryOptimized<TEntity,TRelatedEntity>(ReferenceOwnershipBuilder<TEntity,TRelatedEntity>, Boolean)

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

Applies to