EntityCommandBuffer.Concurrent allows using the command buffer in IParallelForJob but the Create → no entity argument Add/Set combo is flawed. Because there could be a race condition in two consecutive lines of a parallel job like this :
ecb.CreateEntity(archetype);
ecb.SetComponent(data);
or this :
ecb.CreateEntity();
ecb.AddComponent(component);
With many job writing commands to the EntityCommandBuffer.Concurrent at the same time there is a chance to get :
ArgumentException: All entities passed to EntityManager must exist. One of the entities has already been destroyed or was never created.
Because the order could be Create Create Set Set and other unintended pairings
Where the correct order should be Create Set Create Set…
So what we need is a new special command CreateAndAdd or CreateAndSet so that the work to be done later is in one unit. Currently a workaround is having to run only create command and playback them, then loop through them to run Add/Set again.