Why is the accent data incorrect

My edge 1040 Solar is not accurately recording elevation gain.  At times I'm riding up hill. but the Garmin is not recording any gain?