-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unfulfillable nullable contraints are set for complex types with TPH entities #33004
Comments
Minor note: This also affects atomic field types such as |
Note for team: still repros on latest daily. Patch candidate. |
problem is in RelationalPropertyExtensions.IsColumnNullable - there we try to compute nullability of a column that the given property is mapped to. For inheritance scenario we look at declaring type and check if it's part of TPH. However for property of a complex type, declaring type is that complex type so we don't do the proper check. We should find the parent non-complex type instead |
… types with TPH entities When figuring out nullability of columns representing a given property, if property is declared on derived entity in TPH, we make that column nullable. For complex type properties we should be doing the same (and we did), but declaring type of that property is the complex type itself. Instead we should look at the ContainingEntityType rather than just DeclaringType. Fixes #33004
Should we consider patching this (bug in new feature, extremely low risk)? |
… types with TPH entities (#33052) When figuring out nullability of columns representing a given property, if property is declared on derived entity in TPH, we make that column nullable. For complex type properties we should be doing the same (and we did), but declaring type of that property is the complex type itself. Instead we should look at the ContainingEntityType rather than just DeclaringType. Fixes #33004
reopening for patch |
… types with TPH entities When figuring out nullability of columns representing a given property, if property is declared on derived entity in TPH, we make that column nullable. For complex type properties we should be doing the same (and we did), but declaring type of that property is the complex type itself. Instead we should look at the ContainingEntityType rather than just DeclaringType.
… types with TPH entities When figuring out nullability of columns representing a given property, if property is declared on derived entity in TPH, we make that column nullable. For complex type properties we should be doing the same (and we did), but declaring type of that property is the complex type itself. Instead we should look at the ContainingEntityType rather than just DeclaringType.
… types with TPH entities (#33054) When figuring out nullability of columns representing a given property, if property is declared on derived entity in TPH, we make that column nullable. For complex type properties we should be doing the same (and we did), but declaring type of that property is the complex type itself. Instead we should look at the ContainingEntityType rather than just DeclaringType.
merged to release/8.0, closing |
Usually, if a field has the
Required
attribute it is mapped asnullable: false
.But if this field is declared in a TPH entity, that condition may not be possible.
Unfortunately, required-flaged fields within complex types are set as NOT NULL anyway,
which prevents persisting entities that do not implement those fields.
Core for reproduction
Migrations are required (
Add-Migration Init -c CustomContext5
)Include provider and version information
EF Core version: 8.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
The text was updated successfully, but these errors were encountered: