EntityTypeConfiguration<TEntityType>.HasRequired<TTargetEntity>(Expression<Func<TEntityType,TTargetEntity>>) Method

Definition

Configures a required relationship from this entity type. Instances of the entity type will not be able to be saved to the database unless this relationship is specified. The foreign key in the database will be non-nullable.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration<TEntityType,TTargetEntity> HasRequired<TTargetEntity> (System.Linq.Expressions.Expression<Func<TEntityType,TTargetEntity>> navigationPropertyExpression) where TTargetEntity : class;
member this.HasRequired : System.Linq.Expressions.Expression<Func<'EntityType, 'argetEntity>> -> System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration<'EntityType, 'argetEntity (requires 'EntityType : null and 'argetEntity : null)> (requires 'argetEntity : null)
Public Function HasRequired(Of TTargetEntity As Class) (navigationPropertyExpression As Expression(Of Func(Of TEntityType, TTargetEntity))) As RequiredNavigationPropertyConfiguration(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

RequiredNavigationPropertyConfiguration<TEntityType,TTargetEntity>

A configuration object that can be used to further configure the relationship.

Attributes

Applies to