I think this DI container definition does too much. It creates a database connection and an EntityManager. I would recommend separating these different tasks, i.e. I would move the logic for the Connection instance into its own DI container definition.