I tried electric fence, works great until you have a dry spell.
Then they walk right through it.
My new fence is treated lumber and steel.
We left the gate open once in the fall a few years back, a deer got in and could not get out.
I had to go in the garden and "herd" the stupid thing out.
6'6" tall.