共用方式為


IConventionElementTypeBuilder.IsRequired 方法

定義

設定集合的專案是否必須具有值,或可以是 null 。 只有在專案是以可指派 null 的 CLR 類型為基礎時,才能將元素設定為非必要專案。

public Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionElementTypeBuilder? IsRequired (bool? required, bool fromDataAnnotation = false);
abstract member IsRequired : Nullable<bool> * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionElementTypeBuilder
Public Function IsRequired (required As Nullable(Of Boolean), Optional fromDataAnnotation As Boolean = false) As IConventionElementTypeBuilder

參數

required
Nullable<Boolean>

值,指出集合的專案是否不得為 null

fromDataAnnotation
Boolean

指出是否使用資料批註來指定組態。

傳回

如果已設定必要性,則為相同的產生器實例, null 否則為 。

適用於