Is it possible to add CHECK constraint with fluent API in EF7?

前端 未结 3 604
温柔的废话
温柔的废话 2020-12-19 00:18

Is it possible to add CHECK constraint with fluent API in Entity Framework 7?

I need to acheive something like this:

...
ADD CONSTRAINT CK_SomeTable_         


        
3条回答
  •  情书的邮戳
    2020-12-19 00:57

    As of EF 7.0.0-rc1, it isn't possible with the fluent API.

    You can define the constraint manually in the migration

    migrationBuilder.Sql("ALTER TABLE SomeTable ADD CONSTRAINT CK_SomeTable_SomeColumn CHECK (SomeColumn >= X);");
    

提交回复
热议问题