You will want to wire the electrical on the trailer to an auto transfer switch. This switch will be connected to the generator and to the outlet that connects to shore power. Whichever power system is on first, the switch will prevent the other source from trying to turn on and backfeeding into the electric