Using blob assets after baking

I’ve spent a long time trying to understand the documentation and tutorials for blob assets but for some reason I’m struggling to wrap my head around how to use this properly. I’ve followed the example in the blob assets documentation to bake a blob asset:
https://docs.unity3d.com/Packages/com.unity.entities@1.2/manual/blob-assets-create.html#blob-assets-in-baking
So I now have an entity that just holds one IComponentData with a single BlobAssetReference inside it. Now if I understood correctly I need to add that same IComponentData to all the entities that need to use the immutable data stored within it. In my case these entities do not necessarily exist at the start of runtime - I have an ISystem that decides when the entities need to be instantiated and does this via an entity command buffer. So when I instantiate those entities I need to grab the data in the blob asset and add an IComponentData to each entity with the BlobAssetReference.
My question is - what is the correct way to do this?

Here is what I currently do:

public class BlobAuthoring : MonoBehaviour
{
    [SerializeField]
    private int test;

    private class Baker : Baker<BlobAuthoring>
    {
        public override void Bake(BlobAuthoring authoring)
        {
            var builder = new BlobBuilder(Allocator.Temp);

            ref TestData testData = ref builder.ConstructRoot<TestData>();

            testData.ID = authoring.test;

            var blobReference =
                builder.CreateBlobAssetReference<TestData>(Allocator.Persistent);

            builder.Dispose();

            AddBlobAsset<TestData>(ref blobReference, out var hash);
            var entity = GetEntity(TransformUsageFlags.None);
            AddComponent(entity, new BlobAssetTest() { Blob = blobReference });
        }
    }
}

struct TestData
{
    public int ID;
}
struct BlobAssetTest : IComponentData
{
    public BlobAssetReference<TestData> Blob;
}


public partial struct InstantiateSystem : ISystem
{

    BlobAssetReference<TestData> data;

    private void SetField(ref BlobAssetReference<TestData> value)
    {
        data = value;
    }

    [BurstCompile]
    public void OnCreate(ref SystemState state)
    {
        state.RequireForUpdate<BlobAssetTest>();  
    }

    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
        if (!data.IsCreated)
        {
            var entity = SystemAPI.GetSingletonEntity<BlobAssetTest>();
            BlobAssetTest test = SystemAPI.GetComponent<BlobAssetTest>(entity);
            ref BlobAssetReference<TestData> assetReference = ref test.Blob;
            SetField(ref assetReference);
        }
}
}

Then further down in the system I can use the data field to create a new BlobAssetTest component to each entity.

Does this look correct? It seems a bit hacky to me because unless I’m mistaken the BlobAssetTest blob asset will not be a singleton as soon as an entity has been instantiated… I feel like there must be a simpler option…

A follow up question:
Eventually the plan would be to read a JSON file with all the data required for the blob asset. Is it ok to do this in the authoring monobehaviour and add something like a [ExecuteAlways] on the monobehaviour so the data is always ready when I bake? Or is there a better way?

As long as some entity has the value of BlobAssetOwner that was originally on the baked entity with the blob asset, you can copy the blob asset reference freely anywhere. The moment that is no longer true, the blob asset is disposed, and trying to reference it thereafter could result in a crash.

Thanks very much for your reply. So if I understood you correctly as long as I’m careful not to destroy the original baked entity (or possibly transfer ownership) then the reference in ISystem will persist and the way I am doing this using GetSingletonEntity is fine? I guess there are presumably a lot of ways to tackle this… but I envisage using blob assets a lot and I want to be sure I do this correctly!

That matches my understanding.