In this paper we present a learning-based Model Predictive Control (MPC) algorithm based on differentiable optimisation layers. Recent works show that it is possible to include an optimisation problem as a network layer in a Neural Network (NN) architecture. Here the MPC optimisation problem is integrated on the last layer of a NN which is used to estimate the uncertain parameters of the objective function. The NN is then trained online, end-to-end (E2E), based on previous control actions performance. We show that directly targeting the optimality of the control actions leads to improved control results with respect to the standard method of estimating the uncertain parameters and then perform the optimisation. The effectiveness of the proposed method is illustrated on a microgrid energy management problem where the future profile of the electricity price is not known.