Magic Draw

I don't see the on-entry/on-exit/do code in my state diagram

Since MD version 19 (at least recognised it there) it is necessary to copy your code to the body text. See example below: Specification of action code for a state

Is it necessary to specify an action name for on-entry/on-exit/do code?

If there is text in the name fieled (as shown above) it will be considered for code generation. If the name field is left empty the body part is used for code generation. The body text can be longer than one line. An example is shown below. Either specify code in the name filed or the body field.