Assuming you have a lock such as this one, it will be in locked position, when not connected to power. On the other hand, if you supply 12V to your cables the solenoid will pull the piston in.
In order to operate such a device from a microcontroller, you need additional components, such as a power transistor (with heat sink) to control the power supply to the lock, a diode, resistors, as mentioned in the description of above link.
Here is the respective wiring diagram for the linked product. On the Raspberry Pi side you need to connect a digital out GPIO pin to control the power transistor (in the diagram an Arduino is used as example instead of an Raspberry Pi). With the voltage of the GPIO which is connected to the gate of the transistor you can control if current is flowing through the transistor and thus also if you pull in the piston or not.
However, please check also the documentation of the lock you bought, as the specification might be different to the device linked.