Controlling 12V Magnetic Latch Solenoid with RaspberryPi 3b
Your circuit does not work for the solenoid or supply voltage that you have. 

You have a 3 wire (2 coils) self latching solenoid that specifies the common as the negative pin.
The data for the solenoid shows that you have a 4W drive requirement. This means that at 12VDC you need about 340mA to activate each of the solenoid coils (latch and release). 



The transistor you selected is completely unsuitable for your task. It has enough Collector current capability but has a V(CBO and V(CEO) of only 12V. You would never use a device at its absolute maximum rating. 

 

You are going to have to buy suitable devices to drive your solenoid. 

A potential circuit would be as follows and you would need two GPIO pins to drive the latching solenoid: 







simulate this circuit &ndash; Schematic created using CircuitLab

It would be up to you (in software) to ensure the A or B coil is activated for the appropriate length of time to latch and unlatch.   

Note: You must have the pulldown resistors on M3 and M4 to ensure that neither coil is activated as you turn on and boot the R'Pi. The GPIO pins are all set as inputs on power-up, so the 10K Ohm resistors keep M3 and M4 off. 

Update:  The documentation for the solenoid switch you use specifies the polarity of activation (I assume this is required since the latching is by a magnet, so pole polarity sensitive):