Normally this solved with an employment contract: "Anything you write, the copyright is transferred to your employer"