Skip to content

HasCheckConstraint() in model is entirely missing in SQL database #17052

@SidShetye

Description

@SidShetye

ModelBuilder's Entity's HasCheckConstraint() is not reflected in the SQL database.

Steps to reproduce

// example
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    // ...
    modelBuilder.Entity<MyEntity>(entity =>
    {
        // ...
        entity.HasCheckConstraint("CK_ONLY_ONE_NULL", "[Column1] IS NULL AND [Column2] IS NOT NULL OR [Column1] IS NOT NULL AND [Column2] IS NULL");
        // ...
    }
}

Result

The CK_ONLY_ONE_NULL constraint isn't in the local db database

Expectation

The CK_ONLY_ONE_NULL constraint is reflected in the database tables

The HasCheckConstraint extension (undocumented anywhere so far) is in .nuget\packages\microsoft.entityframeworkcore.relational\3.0.0-preview7.19362.6\lib\netstandard2.1\Microsoft.EntityFrameworkCore.Relational.dll namespace Microsoft.EntityFrameworkCore extension class RelationalEntityTypeBuilderExtensions

Further technical details

EF Core version: 3.0.0-preview7.19362.6
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10 x64 v1904
IDE: Visual Studio 2019 16.2.1

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions