Share via


ReferenceOwnershipBuilder<TEntity,TRelatedEntity>.HasMany<TNewRelatedEntity> Method

Definition

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.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder<TRelatedEntity,TNewRelatedEntity> HasMany<TNewRelatedEntity> (System.Linq.Expressions.Expression<Func<TRelatedEntity,System.Collections.Generic.IEnumerable<TNewRelatedEntity>>> navigationExpression = default) where TNewRelatedEntity : class;
override this.HasMany : System.Linq.Expressions.Expression<Func<'RelatedEntity, seq<'NewRelatedEntity>>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder<'RelatedEntity, 'NewRelatedEntity (requires 'RelatedEntity : null and 'NewRelatedEntity : null)> (requires 'NewRelatedEntity : null)
Public Overridable Function HasMany(Of TNewRelatedEntity As Class) (Optional navigationExpression As Expression(Of Func(Of TRelatedEntity, IEnumerable(Of TNewRelatedEntity))) = Nothing) As CollectionNavigationBuilder(Of TRelatedEntity, TNewRelatedEntity)

Type Parameters

TNewRelatedEntity

The entity type that this relationship targets.

Parameters

navigationExpression
Expression<Func<TRelatedEntity,IEnumerable<TNewRelatedEntity>>>

A lambda expression representing the collection navigation property on this entity type that represents the relationship (blog => blog.Posts). If no property is specified, the relationship will be configured without a navigation property on this end.

Returns

CollectionNavigationBuilder<TRelatedEntity,TNewRelatedEntity>

An object that can be used to configure the relationship.

Applies to