-
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
InvalidOperationException with JSON columns and owned entities on update #32621
Comments
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
Hi @ajcvickers, I created an example project to reproduce the error, I published it on my GitHub https://github.com/GHMeyer0/InvalidOperation You need to make a POST with this information curl -X 'POST' \
'https://localhost:32770/api/ActionRules' \
-H 'accept: text/plain' \
-H 'Content-Type: application/json' \
-d '{
"id": "829f7302-235d-4060-b0d2-6349995fbaa6",
"description": "string",
"creationDate": "2023-12-18T15:30:24.893Z",
"parameters": {
"actions": [
{
"email": {
"message": "string"
},
"sms": {
"message": "string"
}
}
]
}
}' Then make a PATCH with these changes curl -X 'PATCH' \
'https://localhost:32770/api/ActionRules/829f7302-235d-4060-b0d2-6349995fbaa6' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '[
{
"op": "add",
"path": "/parameters/actions/1",
"value": {
"email": {
"message": "string"
},
"sms": {
"message": "string"
}
}
}
]' |
@GHMeyer0 The link seems to be broken. |
@ajcvickers, sorry, I had published the repository with private visibility, I already changed it to public |
Note for triage: I believe this is currently by-design because we don't know the key values of the synthesized keys for items of an owned collection. I'm not sure if we should/can do anything better here. For non-JSON, the appropriate fix would be to add a non-synthesized key, but I don't think that works for JSON. This kind of scenario will be better handled by collections of complex types. |
Duplicate of #28594 |
Description
I'm encountering an
InvalidOperationException
when trying to update an entity that contains a JSON column mapping to owned entities. The issue arises specifically with theAcoes
entity within theParametrosDaReguaDeAcao
owned entity. The error suggests an issue with the shadow key property ofAcoes.Id
.Code
stack traces & logs
Include provider and version information
EF Core version: 8.0.3
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: .NET 8.0
Operating system: Linux
IDE: Visual Studio 2022 17.4
Additional Context
I am attempting to update an entity with a JSON column (
Parametros
) that includes a collection of owned entities (Acoes
). This issue occurs during the update operation, where the shadow key propertyAcoes.Id
seems to be causing trouble. Any guidance or suggestions on how to address this issue would be greatly appreciated.The text was updated successfully, but these errors were encountered: