OwnedNavigationBuilder.HasOne 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
HasOne(String) |
Configures a relationship where this entity type has a reference that points to a single instance of the other type in the 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. |
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. |
HasOne(String)
Configures a relationship where this entity type has a reference that points to a single instance of the other type in the relationship.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (string navigationName);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use an overload that accepts a type")]
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (string navigationName);
abstract member HasOne : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
override this.HasOne : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Use an overload that accepts a type")>]
abstract member HasOne : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
override this.HasOne : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder
Public Overridable Function HasOne (navigationName As String) As ReferenceNavigationBuilder
Parameters
- navigationName
- String
The name of the reference navigation property on this entity type that represents the relationship.
Returns
An object that can be used to configure the relationship.
- Attributes
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 WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid relationship.
Applies to
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.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (string relatedTypeName, string navigationName);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (string relatedTypeName, string? navigationName);
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, navigationName As String) 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.
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 WithMany(String) or WithOne(String) to fully configure the relationship. Calling just this method without the chained call will not produce a valid 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.
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceNavigationBuilder HasOne (Type relatedType, string navigationName = default);
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.
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 WithMany(String) or 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