-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Nullable owned entity with nested owned entity always NOT NULL #29457
Comments
@MaximMikhisor This type of model is explicitly disallowed starting with EF Core 6.0. See https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/breaking-changes#nested-optionals |
Dear @ajcvickers , thank you for you answer.
Personaly for me I do not see here any data loss. Please correct me if I understood wrong what does it mean
Does it mean if I made |
@MaximMikhisor For 1, the point is that the nested owned entity may have data, but if the owned entity that it is nested in does not, then the date in the nested entity is lost. For 2, no, because |
Thank you for your explanation. In explanation from your link above:
It is a bit missleading descritpion. It looks like we lost Address data. But as I understood later it means that we lost ContactInfo object. Because at some point it existed in Customer object (even if ContactInfo contained not data itself). But after saving and querying in new place Customer oject will have NULL as ContactInfo. Better example I found here: PS: |
In our real code we have these two owned entities:
It is sad that EF Core does not support this type of model. |
Duplicate of #24558 |
Model example
Note:
<Nullable>enable</Nullable>
is enabled for project.Current behaviour
NestedOwnedEntity
has nestedSomeOwnedEntity
in model example above.RootEntity
has nullableNestedOwned
property.This property is always NOT NULL.
RootEntity
also has nullableSimpleOwned
property.SimpleOwnedEntity
has not any nested owned properies.SimpleOwned
property is NULL insideRootEntity
if it was not assigned before.NestedOwned
property andSimpleOwned
property behave in different way in regard to nullability.Expected behaviour
It is expected that
NestedOwned
property to be NULL if it was not assigned before.At this moment it is always NOT NULL.
Code sample
https://github.com/LineSmarts/EfCoreNotNullNestedOwned
Provider and version information
EF Core version : 5.0.17
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 3.1
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: