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, MinLength will added, at least with Postgres this will fail, because LENGTH() is only supported for strings
- together with the
Id property of type int, the same will happen
- together with
StringLength() two MinLength constraints 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.
When updating to version 8,
EFCore.CheckConstraintsbreaks 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).[Range(1, 5)]on type int,MinLengthwill added, at least with Postgres this will fail, becauseLENGTH()is only supported for stringsIdproperty of type int, the same will happenStringLength()twoMinLengthconstraints will be added, which fails immediately.This can be tested easily with
EFCore.CheckConstraints.Testunit tests:Add
[Required]toBlog.Id,Blog.RatingandBlog.Required.Add this test as well:
It would be great, if this situation can be improved.