EntityTypeConfiguration<TEntityType>.HasOptional<TTargetEntity> 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.
Configures an optional relationship from this entity type. Instances of the entity type will be able to be saved to the database without this relationship being specified. The foreign key in the database will be nullable.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
public System.Data.Entity.ModelConfiguration.Configuration.OptionalNavigationPropertyConfiguration<TEntityType,TTargetEntity> HasOptional<TTargetEntity> (System.Linq.Expressions.Expression<Func<TEntityType,TTargetEntity>> navigationPropertyExpression) where TTargetEntity : class;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public System.Data.Entity.ModelConfiguration.Configuration.OptionalNavigationPropertyConfiguration<TEntityType,TTargetEntity> HasOptional<TTargetEntity> (System.Linq.Expressions.Expression<Func<TEntityType,TTargetEntity>> navigationPropertyExpression) where TTargetEntity : class;
member this.HasOptional : System.Linq.Expressions.Expression<Func<'EntityType, 'argetEntity>> -> System.Data.Entity.ModelConfiguration.Configuration.OptionalNavigationPropertyConfiguration<'EntityType, 'argetEntity (requires 'EntityType : null and 'argetEntity : null)> (requires 'argetEntity : null)
Public Function HasOptional(Of TTargetEntity As Class) (navigationPropertyExpression As Expression(Of Func(Of TEntityType, TTargetEntity))) As OptionalNavigationPropertyConfiguration(Of TEntityType, TTargetEntity)
Type Parameters
- TTargetEntity
The type of the entity at the other end of the relationship.
Parameters
- navigationPropertyExpression
- Expression<Func<TEntityType,TTargetEntity>>
A lambda expression representing the navigation property for the relationship. C#: t => t.MyProperty VB.Net: Function(t) t.MyProperty
Returns
A configuration object that can be used to further configure the relationship.
- Attributes
Applies to
Entity Framework