RelationalEntityTypeExtensions.AddCheckConstraint Method

Definition

Overloads

AddCheckConstraint(IMutableEntityType, String, String)

Creates a new check constraint with the given name on entity type. Throws an exception if a check constraint with the same name exists on the same entity type.

AddCheckConstraint(IConventionEntityType, String, String, Boolean)

Creates a new check constraint with the given name on entity type. Throws an exception if a check constraint with the same name exists on the same entity type.

AddCheckConstraint(IMutableEntityType, String, String)

Creates a new check constraint with the given name on entity type. Throws an exception if a check constraint with the same name exists on the same entity type.

public static Microsoft.EntityFrameworkCore.Metadata.ICheckConstraint AddCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, string name, string sql);
public static Microsoft.EntityFrameworkCore.Metadata.IMutableCheckConstraint AddCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType entityType, string name, string sql);
static member AddCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType * string * string -> Microsoft.EntityFrameworkCore.Metadata.ICheckConstraint
static member AddCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.IMutableEntityType * string * string -> Microsoft.EntityFrameworkCore.Metadata.IMutableCheckConstraint
<Extension()>
Public Function AddCheckConstraint (entityType As IMutableEntityType, name As String, sql As String) As ICheckConstraint
<Extension()>
Public Function AddCheckConstraint (entityType As IMutableEntityType, name As String, sql As String) As IMutableCheckConstraint

Parameters

entityType
IMutableEntityType

The entity type to add the check constraint to.

name
String

The check constraint name.

sql
String

The logical constraint sql used in the check constraint.

Returns

The new check constraint.

Applies to

AddCheckConstraint(IConventionEntityType, String, String, Boolean)

Creates a new check constraint with the given name on entity type. Throws an exception if a check constraint with the same name exists on the same entity type.

public static Microsoft.EntityFrameworkCore.Metadata.IConventionCheckConstraint AddCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType entityType, string name, string sql, bool fromDataAnnotation = false);
static member AddCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.IConventionEntityType * string * string * bool -> Microsoft.EntityFrameworkCore.Metadata.IConventionCheckConstraint
<Extension()>
Public Function AddCheckConstraint (entityType As IConventionEntityType, name As String, sql As String, Optional fromDataAnnotation As Boolean = false) As IConventionCheckConstraint

Parameters

entityType
IConventionEntityType

The entity type to add the check constraint to.

name
String

The check constraint name.

sql
String

The logical constraint sql used in the check constraint.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

The new check constraint.

Applies to