[EFCore] add many Parent entities with Child entities, How to connect them in single SaveChanges
Hello, im trying to sync data in my database with data in external source
there is a example that i have list of MainCategories (parent) and Categories(child)
!! code screen from IDE for better visibility in comments
3 Replies
so there is other way, i can just call SaveChanges for ever iteration in my Foreach and them withdraw new Entity ID
that new Entity Id will be my newChildCategory.ParentId
but due to frequency of that function will be use
i want to optimize it to less SaveChanges()
--
Screen from IDE for better visibility
UPDATE:
so i found a way to add list of child entities to single parent category using
Navigation Property in Parent Entity
but not sure if i have to use AddRange() for children list now