Share via


ReferenceNavigationBuilder<TEntity,TRelatedEntity>.WithMany Method

Definition

Overloads

WithMany(Expression<Func<TRelatedEntity,IEnumerable<TEntity>>>)

Configures this as a one-to-many relationship.

WithMany(String)

Configures this as a one-to-many relationship.

WithMany(Expression<Func<TRelatedEntity,IEnumerable<TEntity>>>)

Configures this as a one-to-many relationship.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<TRelatedEntity,TEntity> WithMany (System.Linq.Expressions.Expression<Func<TRelatedEntity,System.Collections.Generic.IEnumerable<TEntity>>> navigationExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<TRelatedEntity,TEntity> WithMany (System.Linq.Expressions.Expression<Func<TRelatedEntity,System.Collections.Generic.IEnumerable<TEntity>?>>? navigationExpression);
override this.WithMany : System.Linq.Expressions.Expression<Func<'RelatedEntity, seq<'Entity>>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<'RelatedEntity, 'Entity (requires 'RelatedEntity : null and 'Entity : null)>
Public Overridable Function WithMany (navigationExpression As Expression(Of Func(Of TRelatedEntity, IEnumerable(Of TEntity)))) As ReferenceCollectionBuilder(Of TRelatedEntity, TEntity)

Parameters

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

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

Returns

ReferenceCollectionBuilder<TRelatedEntity,TEntity>

An object to further configure the relationship.

Remarks

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.

Applies to

WithMany(String)

Configures this as a one-to-many relationship.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<TRelatedEntity,TEntity> WithMany (string navigationName = default);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<TRelatedEntity,TEntity> WithMany (string? navigationName = default);
override this.WithMany : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<'RelatedEntity, 'Entity (requires 'RelatedEntity : null and 'Entity : null)>
Public Overridable Function WithMany (Optional navigationName As String = Nothing) As ReferenceCollectionBuilder(Of TRelatedEntity, TEntity)

Parameters

navigationName
String

The name of the collection navigation property on the other end of this relationship. If null or not specified, there is no navigation property on the other end of the relationship.

Returns

ReferenceCollectionBuilder<TRelatedEntity,TEntity>

An object to further configure the relationship.

Remarks

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.

Applies to