Design of electronic lock
simulate this circuit &ndash; Schematic created using CircuitLab
Figure 1. A more straight-forward circuit construction.
The fact that you've got a permanent magnet suggests that your lock should be held by magnet and released by the electromagnet. This is the system that is used in prison locks so you need to consider whether or not this is safe if the lock can not be released due to power failure.

Figure 1. A commercial maglock. (Sorry, image source lost.)
I don't know this, but I suspect that for either a power-to-lock or a power-to-release type that three poles are arranged as south-north-south (or vice-versa) and that the coil is wound, pushed into the black slots and potted in position. Once the (electro) magnet hits the keeper the magnetic circuit is closed. As anyone who has played with a horseshoe magnet will know, opening the closed loop is very difficult.

Figure 2. The maglock is an open and shut case. (Illustration mine.)
Here we can see that with the lock open the exposed faces are poles of the magnet. Note also that the magnetic path is twice as wide in the centre pole as on the upper and lower poles so that flux density is fairly constant. Once the lock closes the flux forms a loop through the iron core.
The energise-to-lock type requires power to create the magnetic field. The energise-to-release type requires the electro-magnet to cancel the field of the permanent magnet.