❔ [EFCore] What is the right approach to generate hierarchy id for new child entity?
I Use SQLServer & EF Core. been struggling to find the right approach to generate new h-id for new child entities for a while now. and most approaches online are just straight up inserting duplicates or doing multiple queries with really possible scare-y edge cases that can cause alot of trouble.
3 Replies
like this article shows a method where there guy inserts another
/1/
which is a violation iirc. you can't have duplicate h-id paths
https://www.meziantou.net/using-hierarchyid-with-entity-framework-core.htmMeziantou's blog
Using SQL Server HierarchyId with Entity Framework Core - Gérald Ba...
In this post, I describe how to use the HierarchyId data type with Entity Framework Core.
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1156133743099121674/image.png)
my current approach that does two queries
one query to load the parent. and the other to load the last child.
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.