Switching 12v magentic lock with NPN PN2222

I send this message to Adafruit about that page:

Your page at FAQ | Transistors 101 | Adafruit Learning System gives incorrect calculations for using a bipolar transistor as a switch.

When used as a switch, a bipolar transistor will require much higher current because a transistor in saturation will have a lower gain. Typical values are a base current of 5 to 10% of the maximum collector current. For the 2N2222 and other older switching transistors, 10% is specified in the datasheet.

See page 2 of the datasheet you linked to.
https://www.onsemi.com/pub/Collateral/PN2222-D.PDF

Vce(sat) and Vbe(sat) are specified at a collector current of 500mA and a base current of 50mA. You can look at other manufacturer's datasheets and they specify the same condition where Ib is 1/10 of Ic.

Gain varies from transistor to transistor, even the same batch, and is subject to temperature and drift. You are advocating poor design, where a slight change or a different batch or manufacturer can cause the transistor to not be in saturation and so deliver less voltage to the load and possibly destroy the transistor with excessive heat.

Also please note that with the TIP120 darlington pair, although the current gain is listed as 1000, the datasheet https://www.mouser.com/ds/2/149/TIP120-890130.pdf specifies a base current of 12mA for a collector current of 3A for saturation, and 20mA for 5A. That is a ratio of 1/250, not 1/1000 as your example would lead us to believe.

Please correct this error. Thank you.

I'm shocked at the existence of bad information on professional websites like this.

Paul__B:
The ULN2x03 is essentially obsolete due to poor performance.

True, but you try finding another cheap 8 channel switch with free-wheel diodes in a convenient DIL package...

It's not recommended for new designs, but it will be around for a long time as so much equipment uses
these as multichannel relay drivers and the like.

I figured if you want a switch, use a switch. if you want a dimmer, use a dimmer.