EntityTypeConfiguration<TEntityType>.HasOptional<TTargetEntity> Method (Expression<Func<TEntityType, TTargetEntity>>)
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.
Assembly: EntityFramework (in EntityFramework.dll)
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] [SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public OptionalNavigationPropertyConfiguration<TEntityType, TTargetEntity> HasOptional<TTargetEntity>( Expression<Func<TEntityType, TTargetEntity>> navigationPropertyExpression ) where TTargetEntity : class
Parameters
- navigationPropertyExpression
-
Type:
System.Linq.Expressions.Expression<Func<TEntityType, TTargetEntity>>
A lambda expression representing the navigation property for the relationship. C#: t => t.MyProperty VB.Net: Function(t) t.MyProperty
Return Value
Type: System.Data.Entity.ModelConfiguration.Configuration.OptionalNavigationPropertyConfiguration<TEntityType, TTargetEntity>A configuration object that can be used to further configure the relationship.
Type Parameters
- TTargetEntity
The type of the entity at the other end of the relationship.