Yes, an electric fence will work to a large degree. My parents lived in northern MN with a high deer population and they used a fence successfully to keep deer away from their gardens and landscaping.
It’s not a 100% solution, but deer fear getting trapped somewhere, so unless you have a very high value food source inside the fence, most deer won’t risk getting inside a fence that’s even 5 feet high.
Also, when you put up the fence, don’t put lots of flags or “high vis” tape on it. Just let the deer walk into it and get zapped. Deer don’t understand what happened when they got zapped, they seem to just know that whatever it was, they want to stay far away from it. Which is just what you want.
The only downside is that when deer touch a fence, they run forward. So then you end up with a torn up fence until the deer learn to stay away. It’s just the price you pay, but just know that you have to check your fence a lot and watch your controller for the “down” signal.
Grouse