Made the data access work with entities instantiated outside the context