You would use the same set up with a diode and transistor for a solenoid as well.
With Smaller Transistor (P2N2222A or a BC337):
With Tip120:
Link for Motor Shield tutorial: https://learn.sparkfun.com/tutorials/tb6612fng-hookup-guide?_ga=2.227433246.2072068385.1551701674-349683115.1523944725