-
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
Azure Cosmos DB provider should default to implicit ownership #24803
Comments
Related - #6787 to allow configuring owned types without using deeply nested lambdas. |
Allow to reconfigure STETs as regular entity types Fixes #24803
Allow to reconfigure STETs as regular entity types Fixes #24803
Allow to reconfigure STETs as regular entity types Fixes #24803
Allow to reconfigure STETs as regular entity types Fixes #24803
Allow to reconfigure STETs as regular entity types Rerun CosmosDiscriminatorConvention and BaseTypeDiscoveryConvention when ownership changes Keep OwnedNavigationBuilder.DependentEntityType updated Fixes #24803
If I am reading the Merge correctly it only addresses issue 1. Is Issue 2 being tracked separately?
We are currently having to work around this by adding and serialising Guid keys on all child entities in complex types so that EF can track them properly so this second issue was of real interest to me and I would not like to see it get lost. Especially since it looked like it was going to get fixed in EFCore6. |
@ACROV You are reading correctly. #17306 will allow value converters that output raw JSON, though it means that all complex types will become a black box for query. You shouldn't need to create any keys for owned entities, EF Core creates shadow keys by convention that are not persisted, if there's an issue with them please file it separately. |
@AndriySvyryd, @ajcvickers, @JeremyLikness - Apologies in advance for my limited EF Core for Cosmos understanding.. if you can reach me half way...
The problem i think we ran across is that we do not keep a persistent DB context when using Blazor WASM (Client only) app. So in this case.. should we be adding an "Id" to every owned class going forward?
|
@ajcvickers - in this post you mentioned one could add a private CLR property to the owned entity. #19856
can you expand on this - what does it look like? We tried but did not work for us. |
If that works, then yes. In most cases EF will generate the values for the shadow keys on owned entity types. So, unless something is failing you don't need to preserve them. |
I know it's a small thing but my brain kind of hurts... when needing to update an entity Makes me feel like I'm going off course on a work round, and from readability standpoint reading Add feels wrong when really updating (even if that's what its doing under the covers). Would it be possible to introduce a new method on Microsoft.EntityFrameworkCore.Cosmos SDK DB Context... and name that method UpdateDisconnectedEntity() or something like that? Or add the "Add" and "Mark as Modified" somewhere in documentation for Microsoft.EntityFrameworkCore.Cosmos for BlazorWASM. @JeremyLikness - thoughts? since you work with Blazor WASM. |
The typical case for document databases is to store a root entity and serialize its children, including single and collection navigations, as sub-properties rather than separately tracked entities. The EF Core provider for Azure Cosmos DB currently has two issues with this convention. First, complex entities in the graph are assumed to be independently tracked and therefore modeling the default behavior requires explicitly configuring ownership. For larger graphs this has a negative impact on maintainability. Second, complex entities shouldn't have to be tracked independently. They should be considered serializable types owned by the root entity that are serialized directly.
As a solution, I'd like to see:
Example from Cosmos DB getting started app:
Currently I have to do this configuration, whereas with the SDK v4 it "just works":
OwnsMany
is fine at one level but gets complicated when there are multiple nested complex types. Using a value converter makes me lose the ability to query on the summary. It would be great if we could just configure theFamily
as aDbSet
and only have to configure the partition key.The text was updated successfully, but these errors were encountered: