In this paper, a new energy management model is proposed to determine the optimal scheduling of an office building which includes electric vehicle (EV) charging piles, batteries, and rooftop photovoltaic systems. To optimally manage the electricity procurement of the building and mitigate the rate of transformer aging, the building energy management system (BEMS) employs the flexibility of batteries and EV charging. In the proposed model, to incentivize EV owners to offer their flexibility, the BEMS organizes a transactive market among plugged-in EVs. To this end, EV owners submit their response curves and the target state-of-charge to the BEMS. Then, the transactive market is cleared to determine the market-clearing price for each EV, the optimal EV charging decisions, and accordingly, the scheduling of office building. Also, to model the correlated uncertainties of solar power generation and demand, the distributionally robust chance-constrained method is employed. Moreover, the “Big-M” technique and the piecewise linear approximation method are utilized to linearize the optimization problem. Finally, the case of a building with 100 charging piles is studied. The numerical results illustrate a decrease in the total operating cost of BEMS and the rate of transformer aging compared to uncontrolled charging and direct control approaches. • Developing a TE model to incentivize EVs’ participation in the energy management program. • Developing a new response curve model for EV owners. • Incorporating the transformer’s loss of life in the proposed TE model. • Developing a distributionally robust chance-constrained building energy management model. • Linearizing non-linear equations to mitigate the computational complexity.