You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a ClassA which has a list of ClassBs, ClassB with a list of ClassCs, with parent child relations in dbcontext.
I have configured Dtos and CreateUpdateDtos for above classes to follow the usage of CrudAppService class.
When using the inherited endpoint in CrudAppService to update the entities, would throw exception about entity tracking
create a new ClassA entity with one child ClassB entity and one child ClassC entity within classB
copy the result data
go to ClassA PUT endpoint, paste the above data as body, copy paste the id as path variable id
modify any non-id value in the body
execute the endpoint, got error result returned
Expected behavior
the multi-level parent-child entities should save gracefully without exception
Actual behavior
throws exception
The instance of entity type 'ClassC' cannot be tracked because another instance with the key value '{Id: 3a17dd15-6be3-06dc-5ebb-103bf221f4c3}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.
Regression?
No response
Known Workarounds
No response
Version
9.0.3
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
I'm not sure if I'm doing a correct way writing these code, but when I use the similar code for a two-level parent child relationship entities, it is working nicely for me. So if this is not the correct way of doing it, please help me understand how to write the code for a three-level parent child relationship.
The text was updated successfully, but these errors were encountered:
baibai-cbd
changed the title
Multi-level entities update throws another entity with same id already tracked exception
Multi-level entities update throws another entity with same key value already tracked exception
Feb 3, 2025
Is there an existing issue for this?
Description
I have a ClassA which has a list of ClassBs, ClassB with a list of ClassCs, with parent child relations in dbcontext.
I have configured Dtos and CreateUpdateDtos for above classes to follow the usage of CrudAppService class.
When using the inherited endpoint in CrudAppService to update the entities, would throw exception about entity tracking
Reproduction Steps
https://github.com/baibai-cbd/playground.hierarchy
sample repo to reproduce the issue
Expected behavior
the multi-level parent-child entities should save gracefully without exception
Actual behavior
throws exception
Regression?
No response
Known Workarounds
No response
Version
9.0.3
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
I'm not sure if I'm doing a correct way writing these code, but when I use the similar code for a two-level parent child relationship entities, it is working nicely for me. So if this is not the correct way of doing it, please help me understand how to write the code for a three-level parent child relationship.
The text was updated successfully, but these errors were encountered: