EntityTypeConfiguration<TEntityType>.HasRequired<TTargetEntity> Method

Entity Framework 5.0

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.

Namespace:  System.Data.Entity.ModelConfiguration
Assembly:  EntityFramework (in EntityFramework.dll)

public RequiredNavigationPropertyConfiguration<TEntityType, TTargetEntity> HasRequired<TTargetEntity>(
	Expression<Func<TEntityType, TTargetEntity>> navigationPropertyExpression
)
where TTargetEntity : class

Type Parameters

TTargetEntity

The type of the entity at the other end of the relationship.

Parameters

navigationPropertyExpression
Type: System.Linq.Expressions.Expression<Func<TEntityType, TTargetEntity>>

A lambda expression representing the navigation property for the relationship. For example, in C# t => t.MyProperty and in Visual Basic .Net Function(t) t.MyProperty.

Return Value

Type: System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration<TEntityType, TTargetEntity>
A configuration object that can be used to further configure the relationship.
Show: