So technically its likely that the problem was back EMF from your inductor, rather than "transient voltage" (although the back EMF is sort of transient, and it does cause a voltage, so maybe that counts as a transient voltage). The solution to the back EMF is to put a diode in parallel with L1, as you have done in the first image.
Using a TVS diode as you have in the first image will also work, but the transient voltage suppression part isn't really doing anything, any diode (suitably rated for current) will work.
Interestingly, although your second arrangement wouldn't work with a normal diode, it probably sort of maybe does work with a TVS diode. I wouldn't recommend doing this, because it could do some weird stuff to your power supply.
In summary, feel free to use the arrangement you have in the first picture, and you can use a TVS which will protect you a tiny bit more from random static or whatever on the inductor contacts (although I doubt it will really be different to a normal diode).