-
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
CosmosDb OwnsMany is broken when multiple child entities are saved without int Id values specified #33573
Comments
Apologies for taking so long to even try out the 8.0.2 release to ensure working. Diverted elsewhere for a while. |
Another observation is that the alpha does not persist the Id property at all in the backend (my expected behaviour). The 8.0.2/3/4 releases all persist the value 0 for the Id, hence I guess why they throw an exception due to all having 0 as their Id for all children that have none specified. |
Ah so looking at the PR code, and here it was lost on me that I would need to apply a switch to enable the functionality. I applied I'll do some more testing (with 8.0.4) just to be sure. |
@markphillips100 I'm unable to repro the behavior you are seeing. With the model in https://github.com/markphillips100/efcore-cosmos-sample/tree/dotnet8 and not setting any AppContext switches I'm able to save multiple children and However if you are satisfied with the current behavior in 9.0.0-preview.3 and 8.0.4 with the AppContext switch set, then I'll consider this issue resolved. |
@AndriySvyryd did you change the PackageReference versions in the repo before attepting to reproduce? It is currently set to use 8.0.0 so you must set to either 8.0.2, 8.0.3, or 8.0.4. |
@AndriySvyryd of course I am not happy with using the alpha release where the functionality worked and I never tried 9.0.0-preview.3 as you suggested. |
@ajcvickers @AndriySvyryd please reopen as this is not resolved. |
I've updated the sample to use 8.0.4 so just pull the repo and use branch dotnet8. This one will break if you post many children without specifying the child Id in each. To get it working, uncomment line here. |
Basically I'd like to know if it is expected to include the switch to obtain the behaviour I require from 8.0.2 onwards. I'm okay with using it but just need the clarification. |
Right, you added the |
@AndriySvyryd right, I just noticed that. This was my bad as I brought it inline with my real use case which does have the So can you just clarify please that I must use the switch
|
@markphillips100 To get the same behavior across all versions, instead of using the switch you can explicitly mark the
|
Thank you. I shall give that a try. Ideally not using the switch would be best. |
@AndriySvyryd that works perfectly so thank you very much. |
I created bug #32410 a while back which appeared to be resolved, or at least it was in the alpha nightly release I tested (9.0.0-alpha.1.23417.8).
Using the same sample I created for that issue I tested EFCore versions 8.0.2, 8.0.3, and 8.0.4 and all are not working as expected, well partly.
If only one child entity is saved in the parent's child collection without specifying the Id or the foreign key then all is well with the alpha version and all 3 of previously mentioned v8.0.x runtimes.
So this data persists fine and generates an int Id value in the backend for the only child:
If however, 2 or more children are in the collection to be saved at the backend, only the alpha version works. All the other versions fail with the following exception:
So it is not possible to save this document:
The text was updated successfully, but these errors were encountered: