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
Document behaviors around setting owned navigations to null #4669
Comments
Note for team: still repros on latest daily; not a regression. |
Note: also repros for non-json owned entities |
Note for triage: I investigated this more. If this was not an owned type, this would be the correct behavior. This is because, in effect, the Given that we are unsure where owned types are going, I propose we do nothing here immediately. It's also worth noting that this works: myDbContext.Update(owner);
owner.Data.MoreData = null;
myDbContext.SaveChanges(); This is because in this case EF is tracking the entity when the nav is set to null, so EF correctly detects this as a delete. |
The example only works if |
Structured data in nested Json can't be set to null
Currently it is not possible to update nested structured data in a json column to null, just by attaching an entity to the context.
I can understand this behavior for non json columns as it would be more involved to update the database. But for json columns the serialization should not be a merge of navigation and non navigation properties.
Given the example below. After attaching
owner
to the database and saving it, theMoreData
property should be null.To be clear the data we want to attach is coming via an asp controller.
To make this work right now, we would need to:
isNull
)isNull
set it to a temporary value.isNull
remove the temporary value again.Maybe there is another solution? So far we were not able to find one which did not involve dealing with the previous data or tricking the change tracker into recognizing the non null state first.
Code
Version information
EF Core version: 8.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer (8.0.1)
Target framework: .NET 8
Operating system: Windows 11
The text was updated successfully, but these errors were encountered: