Drive Solenoid with RPi
1) your solenoid connections are both wrong,  this is a low side switch with Red (V+) power applied to load..

2) your component resistances are missing e.g. DCR of solenoid , Rce of NPN transistor ( Rce=Vsat/Isat) and hFE of transistor considering the switched current gain is more like 10% of the linear hFE. 


take a 12W solenoid. 


e.g. DCR is 12 Ohms i.e. 12V/1A= 12Ohms
a tiny transistor may not be enough
if temp rise is 200’C/W, Pt must be &lt; 1/5 W thus Rce&lt; 200mOhm and Ib ~ 10% x Ic = 100mA which you cannot do with (5V -0.7)/2.4K. 
But could  do with an NFET Ron &lt;0.2 



This example is not a general solution yet illustrates you must be more careful with connections and double-check (always) and understand how switches work and dont work by not having enough bias or low enough resistance.