RelationalEntityTypeBuilderExtensions.HasCheckConstraint Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
HasCheckConstraint(EntityTypeBuilder, String, String)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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);
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the entity type.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint(OwnedNavigationBuilder, String, String)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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);
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the navigation.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint(EntityTypeBuilder, String, String, Action<CheckConstraintBuilder>)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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);
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the entity type.
- Attributes
Remarks
See Database check constraints for more information and examples.
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
The same builder instance if the check constraint was configured,
null
otherwise.
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint(OwnedNavigationBuilder, String, String, Action<CheckConstraintBuilder>)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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);
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the navigation.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String, Action<CheckConstraintBuilder>)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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;
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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)
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the entity type.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint<TEntity>(EntityTypeBuilder<TEntity>, String, String)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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;
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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)
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the entity type.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity,TDependentEntity>, String, String)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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;
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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)
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
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.
Returns
A builder to further configure the navigation.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
HasCheckConstraint<TOwnerEntity,TDependentEntity>(OwnedNavigationBuilder<TOwnerEntity, TDependentEntity>, String, String, Action<CheckConstraintBuilder>)
Caution
Configure this using ToTable(t => t.HasCheckConstraint()) instead.
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;
[System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")]
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)
[<System.Obsolete("Configure this using ToTable(t => t.HasCheckConstraint()) instead.")>]
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
A builder to further configure the navigation.
- Attributes
Remarks
See Database check constraints for more information and examples.
Applies to
Entity Framework