change the way to create entity manager in config and context