I have been building some complex state machines from c# with great success but cannot seem to create transitions from the Entry node to a state using code. I can do this manually but that won’t work for our project. How do I create the nodes circled in the image using C#? I created these manually…

I have tried AddStateMachineTransition and also AddEntryTransition but they don’t add a transition inside a state machine from the Entry node to one of the states as shown here.
Thanks for any help…
AddEntryTransition works for me:
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
public class SM : MonoBehaviour
{
[MenuItem("MyMenu/Create Controller")]
static void CreateController()
{
// Creates the controller
var controller = AnimatorController
.CreateAnimatorControllerAtPath("Assets/Mecanim/StateMachineTransitions.controller");
var rootStateMachine = controller.layers[0].stateMachine;
var stateA1 = rootStateMachine.AddState("A1");
var stateB1 = rootStateMachine.AddState("B1");
stateA1.AddExitTransition();
rootStateMachine.AddAnyStateTransition(stateA1);
rootStateMachine.AddEntryTransition(stateB1);
rootStateMachine.defaultState = stateA1;
}
}