how to add a ScriptableObject to a Prefab in a script?

hi,
I am trying to add a ScriptableObject to a Prefab (unity 2018.3.0f2) asset via a custom Property Drawer script.
this used to work fine in Unity 5 but since switching to 2018 and with the new Prefab system I have run into some problems with my scripts that I dont know how to fix.

I have attached a zip with an example project showing the problems

  1. open the project and open the SampleScene.unity scene
  2. open from menu: Window → SOSelector
  3. here you can select the Type of the ScriptableObject to Create (SOTypeOne, SoTypeTwo)
  4. in the Project view navigate to Assets and select the PrefabTest asset
  5. in the inspector press “Open Prefab”
  6. under the TestSOSelectorWindow component press the “+” buton next to Param1

what happens is that the ScriptableObject is created and added to the prefab - the problem is the prefab being edited is closed (when AssetDatabase.SaveAssets() is called on line 105 of SOTypeDrawer.cs) and when I open the prefab again it value is set to None and Param1 is not set to the created ScriptableObject (I was using fieldInfo.SetValue to set the field to the scriptableObject on line 102 of SOTypeDrawer.cs)

Presumably i need to do this a different way to work with the newer Prefab system instead of with AssetDatabase but I could not see how?
any ideas?

6403878–714609–AddScriptableObjectToPrefab.zip (41.4 KB)

anyone even know if its possible to add an asset to a prefab through PrefabUtility (Unity - Scripting API: PrefabUtility) it seems to only handle gameobjects?

https://docs.unity3d.com/ScriptReference/AssetDatabase.AddObjectToAsset.html
as object set scriptableobject, as path set prefab path