An electric fence doesn't always work. I know somebody who has a Beagle, and while the dog is deathly afraid to go anywhere near the electric fence, he did get out one time. He just ran through the shock.
Is it not a possibility to fence your yard? I know that that isn't a possibility for us, so I just have to always have our dogs on leash.
Whatever you decide to do, good luck with it!