Yes, you can do this, but it’s not a great idea. For a little more money, you can have an interlock or transfer switch installed. It’s way safer and easier in the long run.
This transfer switch is a good option. It supports up to 16 circuits and costs about the same as the ‘workaround’ methods people suggest.