-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
When updating to version 8, EFCore.CheckConstraints breaks EF code first usage.
I mainly use Postgres.
It turned out, that the usage of [Required] attribute creates additional constraints, which did not show up in version 6 (and probably in version 7).
- together with
[Range(1, 5)]on type int,MinLengthwill added, at least with Postgres this will fail, becauseLENGTH()is only supported for strings - together with the
Idproperty of type int, the same will happen - together with
StringLength()twoMinLengthconstraints will be added, which fails immediately.
This can be tested easily with EFCore.CheckConstraints.Test unit tests:
Add [Required] to Blog.Id, Blog.Rating and Blog.Required.
Add this test as well:
[Fact]
public virtual void RequiredNoString()
{
var entityType = BuildEntityType<Blog>();
var constraints = entityType.GetCheckConstraints();
Assert.DoesNotContain(constraints, c => c.Name == "CK_Blog_Id_MinLength");
Assert.DoesNotContain(constraints, c => c.Name == "CK_Blog_Rating_MinLength");
}
It would be great, if this situation can be improved.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels