Share via


ReferenceOwnershipBuilder.HasOne Method

Definition

Overloads

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.

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.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (string relatedTypeName, string navigationName = default);
abstract member HasOne : string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
override this.HasOne : string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
Public Overridable Function HasOne (relatedTypeName As String, Optional navigationName As String = Nothing) As ReferenceNavigationBuilder

Parameters

relatedTypeName
String

The name of the entity type that this relationship targets.

navigationName
String

The name of the reference 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.

Applies to

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.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (Type relatedType, string navigationName = default);
abstract member HasOne : Type * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
override this.HasOne : Type * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
Public Overridable Function HasOne (relatedType As Type, Optional navigationName As String = Nothing) As ReferenceNavigationBuilder

Parameters

relatedType
Type

The entity type that this relationship targets.

navigationName
String

The name of the reference 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.

Applies to