IConventionForeignKey.SetIsRequired(Nullable<Boolean>, Boolean) Method

Definition

Sets a value indicating whether the principal entity is required. If true, the dependent entity must always be assigned to a valid principal entity.

C#
public void SetIsRequired (bool? required, bool fromDataAnnotation = false);
C#
public bool? SetIsRequired (bool? required, bool fromDataAnnotation = false);

Parameters

required
Nullable<Boolean>

A value indicating whether the principal entity is required.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

The configured requiredness.

Applies to

Product Versions
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0