Update Prefab During Editor Mode

Currently I succeed to update a prefab during editor mode (via command line).
I’m making changes to the properties of a gameObject and then use:
EditorUtility.SetDirty(gameObject);

This works as expected.

Now I want to take a container of GameObjects from the prefab, delete the GameObjects and add new ones to the container (Transform).

How can I achieve this?

I tried to use DetachChildren/Destroy for removing the GameObjects - this doesn’t work…
Also I tried to add new GameObject by setting it’s transform parent to the GameObjects container I got - this doesn’t work also.

I succeed to delete the GameObject using DestroyImmediate(obj, true);

Now I’m struggling to add new GameObjects to the Transform - tried setting the parent of the new create GameObject with no success…