RelationalEntityTypeBuilderExtensions.HasCheckConstraint Method

Definition

Overloads

HasCheckConstraint(EntityTypeBuilder, String, String)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint(OwnedNavigationBuilder, String, String)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint(EntityTypeBuilder, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint(IConventionEntityTypeBuilder, String, String, Boolean)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint(OwnedNavigationBuilder, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>, String, String)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

HasCheckConstraint(EntityTypeBuilder, String, String)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder entityTypeBuilder, string name, string sql);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder entityTypeBuilder, string name, string? sql);
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
<Extension()>
Public Function HasCheckConstraint (entityTypeBuilder As EntityTypeBuilder, name As String, sql As String) As EntityTypeBuilder

Parameters

entityTypeBuilder
EntityTypeBuilder

The entity type builder.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

Returns

EntityTypeBuilder

A builder to further configure the entity type.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint(OwnedNavigationBuilder, String, String)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder ownedNavigationBuilder, string name, string? sql);
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder
<Extension()>
Public Function HasCheckConstraint (ownedNavigationBuilder As OwnedNavigationBuilder, name As String, sql As String) As OwnedNavigationBuilder

Parameters

ownedNavigationBuilder
OwnedNavigationBuilder

The navigation builder for the owned type.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

Returns

OwnedNavigationBuilder

A builder to further configure the navigation.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint(EntityTypeBuilder, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder entityTypeBuilder, string name, string sql, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> buildAction);
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder * string * string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder
<Extension()>
Public Function HasCheckConstraint (entityTypeBuilder As EntityTypeBuilder, name As String, sql As String, buildAction As Action(Of CheckConstraintBuilder)) As EntityTypeBuilder

Parameters

entityTypeBuilder
EntityTypeBuilder

The entity type builder.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

buildAction
Action<CheckConstraintBuilder>

An action that performs configuration of the check constraint.

Returns

EntityTypeBuilder

A builder to further configure the entity type.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint(IConventionEntityTypeBuilder, String, String, Boolean)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string name, string sql, bool fromDataAnnotation = false);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionCheckConstraintBuilder? HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder entityTypeBuilder, string name, string? sql, bool fromDataAnnotation = false);
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder * string * string * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionEntityTypeBuilder * string * string * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionCheckConstraintBuilder
<Extension()>
Public Function HasCheckConstraint (entityTypeBuilder As IConventionEntityTypeBuilder, name As String, sql As String, Optional fromDataAnnotation As Boolean = false) As IConventionEntityTypeBuilder
<Extension()>
Public Function HasCheckConstraint (entityTypeBuilder As IConventionEntityTypeBuilder, name As String, sql As String, Optional fromDataAnnotation As Boolean = false) As IConventionCheckConstraintBuilder

Parameters

entityTypeBuilder
IConventionEntityTypeBuilder

The entity type builder.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionEntityTypeBuilder
IConventionCheckConstraintBuilder

The same builder instance if the check constraint was configured, null otherwise.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint(OwnedNavigationBuilder, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder HasCheckConstraint (this Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder ownedNavigationBuilder, string name, string sql, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> buildAction);
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder * string * string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> -> Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder
<Extension()>
Public Function HasCheckConstraint (ownedNavigationBuilder As OwnedNavigationBuilder, name As String, sql As String, buildAction As Action(Of CheckConstraintBuilder)) As OwnedNavigationBuilder

Parameters

ownedNavigationBuilder
OwnedNavigationBuilder

The navigation builder for the owned type.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

buildAction
Action<CheckConstraintBuilder>

An action that performs configuration of the check constraint.

Returns

OwnedNavigationBuilder

A builder to further configure the navigation.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> HasCheckConstraint<TEntity> (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> entityTypeBuilder, string name, string sql) where TEntity : class;
public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> HasCheckConstraint<TEntity> (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> entityTypeBuilder, string name, string? sql) where TEntity : class;
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function HasCheckConstraint(Of TEntity As Class) (entityTypeBuilder As EntityTypeBuilder(Of TEntity), name As String, sql As String) As EntityTypeBuilder(Of TEntity)

Type Parameters

TEntity

The entity type being configured.

Parameters

entityTypeBuilder
EntityTypeBuilder<TEntity>

The entity type builder.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

Returns

EntityTypeBuilder<TEntity>

A builder to further configure the entity type.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> HasCheckConstraint<TEntity> (this Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<TEntity> entityTypeBuilder, string name, string sql, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> buildAction) where TEntity : class;
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> * string * string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> -> Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function HasCheckConstraint(Of TEntity As Class) (entityTypeBuilder As EntityTypeBuilder(Of TEntity), name As String, sql As String, buildAction As Action(Of CheckConstraintBuilder)) As EntityTypeBuilder(Of TEntity)

Type Parameters

TEntity

The entity type being configured.

Parameters

entityTypeBuilder
EntityTypeBuilder<TEntity>

The entity type builder.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

buildAction
Action<CheckConstraintBuilder>

An action that performs configuration of the check constraint.

Returns

EntityTypeBuilder<TEntity>

A builder to further configure the entity type.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>, String, String)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<TOwnerEntity,TDependentEntity> HasCheckConstraint<TOwnerEntity,TDependentEntity> (this Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<TOwnerEntity,TDependentEntity> ownedNavigationBuilder, string name, string? sql) where TOwnerEntity : class where TDependentEntity : class;
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<'OwnerEntity, 'DependentEntity (requires 'OwnerEntity : null and 'DependentEntity : null)> * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<'OwnerEntity, 'DependentEntity (requires 'OwnerEntity : null and 'DependentEntity : null)> (requires 'OwnerEntity : null and 'DependentEntity : null)
<Extension()>
Public Function HasCheckConstraint(Of TOwnerEntity As Class, TDependentEntity As Class) (ownedNavigationBuilder As OwnedNavigationBuilder(Of TOwnerEntity, TDependentEntity), name As String, sql As String) As OwnedNavigationBuilder(Of TOwnerEntity, TDependentEntity)

Type Parameters

TOwnerEntity
TDependentEntity

Parameters

ownedNavigationBuilder
OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>

The navigation builder for the owned type.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

Returns

OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>

A builder to further configure the navigation.

Remarks

See Database check constraints for more information.

Applies to

HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>, String, String, Action<CheckConstraintBuilder>)

Configures a database check constraint when targeting a relational database.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<TOwnerEntity,TDependentEntity> HasCheckConstraint<TOwnerEntity,TDependentEntity> (this Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<TOwnerEntity,TDependentEntity> ownedNavigationBuilder, string name, string sql, Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> buildAction) where TOwnerEntity : class where TDependentEntity : class;
static member HasCheckConstraint : Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<'OwnerEntity, 'DependentEntity (requires 'OwnerEntity : null and 'DependentEntity : null)> * string * string * Action<Microsoft.EntityFrameworkCore.Metadata.Builders.CheckConstraintBuilder> -> Microsoft.EntityFrameworkCore.Metadata.Builders.OwnedNavigationBuilder<'OwnerEntity, 'DependentEntity (requires 'OwnerEntity : null and 'DependentEntity : null)> (requires 'OwnerEntity : null and 'DependentEntity : null)
<Extension()>
Public Function HasCheckConstraint(Of TOwnerEntity As Class, TDependentEntity As Class) (ownedNavigationBuilder As OwnedNavigationBuilder(Of TOwnerEntity, TDependentEntity), name As String, sql As String, buildAction As Action(Of CheckConstraintBuilder)) As OwnedNavigationBuilder(Of TOwnerEntity, TDependentEntity)

Type Parameters

TOwnerEntity

The entity type owning the relationship.

TDependentEntity

The dependent entity type of the relationship.

Parameters

ownedNavigationBuilder
OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>

The navigation builder for the owned type.

name
String

The name of the check constraint.

sql
String

The logical constraint sql used in the check constraint.

buildAction
Action<CheckConstraintBuilder>

An action that performs configuration of the check constraint.

Returns

OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>

A builder to further configure the navigation.

Remarks

See Database check constraints for more information.

Applies to