src/Shared/EntityFramework/ModelConfiguration/EntityTypeConfiguration.cs
/// <summary>
/// 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.
/// </summary>
/// <typeparam name="TTargetEntity"> The type of the entity at the other end of the relationship. </typeparam>
/// <param name="navigationPropertyExpression"> A lambda expression representing the navigation property for the relationship. C#: t => t.MyProperty VB.Net: Function(t) t.MyProperty </param>
/// <returns> A configuration object that can be used to further configure the relationship. </returns>
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.
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 .
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
        public OptionalNavigationPropertyConfiguration<TEntityType, TTargetEntity> HasOptional<TTargetEntity>(
            Expression<Func<TEntityType, TTargetEntity>> navigationPropertyExpression)
            where TTargetEntity : class
        {
            Check.NotNull(navigationPropertyExpression, "navigationPropertyExpression");
            return new OptionalNavigationPropertyConfiguration<TEntityType, TTargetEntity>(
                _entityTypeConfiguration.Navigation(navigationPropertyExpression.GetSimplePropertyAccess().Single()));
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] public OptionalNavigationPropertyConfiguration < TEntityType , TTargetEntity > HasOptional < TTargetEntity > ( Expression < Func < TEntityType , TTargetEntity > > navigationPropertyExpression ) where TTargetEntity : class { Check . NotNull ( navigationPropertyExpression , " " ) ; return new OptionalNavigationPropertyConfiguration < TEntityType , TTargetEntity > ( _entityTypeConfiguration . Navigation ( navigationPropertyExpression . GetSimplePropertyAccess ( ) . Single ( ) ) ) ; }
Configures an optional relationship from this entity type.
Configures an optional relationship from this entity type .
A configuration object that can be used to further configure the relationship.
A configuration object that can be used to further configure the relationship .
navigationPropertyExpression
Expression<Func<TEntityType, TTargetEntity>>
A lambda expression representing the navigation property for the relationship.
A lambda expression representing the navigation property for the relationship .
typeparam
The type of the entity at the other end of the relationship.
The type of the entity at the other end of the relationship .