EntityTypeBuilder.HasMany Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
HasMany(String) |
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship. |
HasMany(String, String) |
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship. |
HasMany(Type, String) |
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship. |
HasMany(String)
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (string navigationName);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use the generic overload instead")]
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (string navigationName);
abstract member HasMany : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
override this.HasMany : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use the generic overload instead")>]
abstract member HasMany : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
override this.HasMany : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
Public Overridable Function HasMany (navigationName As String) As CollectionNavigationBuilder
Parameters
- navigationName
- String
The name of the collection navigation property on this entity type that represents the relationship. The navigation must be a CLR property on the entity type.
Returns
An object that can be used to configure the relationship.
- Attributes
Remarks
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.
Applies to
HasMany(String, String)
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (string relatedTypeName, string navigationName = default);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (string relatedTypeName, string navigationName);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (string relatedTypeName, string? navigationName);
abstract member HasMany : string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
override this.HasMany : string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
Public Overridable Function HasMany (relatedTypeName As String, Optional navigationName As String = Nothing) As CollectionNavigationBuilder
Public Overridable Function HasMany (relatedTypeName As String, navigationName As String) As CollectionNavigationBuilder
Parameters
- relatedTypeName
- String
The name of the entity type that this relationship targets.
- navigationName
- String
The name of the collection navigation property on this entity type that represents the relationship. If no property is specified, the relationship will be configured without a navigation property on this end.
Returns
An object that can be used to configure the relationship.
Remarks
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.
Applies to
HasMany(Type, String)
Configures a relationship where this entity type has a collection that contains instances of the other type in the relationship.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (Type relatedType, string navigationName = default);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder HasMany (Type relatedType, string? navigationName = default);
abstract member HasMany : Type * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
override this.HasMany : Type * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.CollectionNavigationBuilder
Public Overridable Function HasMany (relatedType As Type, Optional navigationName As String = Nothing) As CollectionNavigationBuilder
Parameters
- relatedType
- Type
The entity type that this relationship targets.
- navigationName
- String
The name of the collection navigation property on this entity type that represents the relationship. If no property is specified, the relationship will be configured without a navigation property on this end.
Returns
An object that can be used to 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.
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.
Applies to
Entity Framework
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for