Sex is painful

Here's my story: 
I got in a relationship when I was 16 and lost my virginity at 17. We were both virgins so we were inexperienced and it didn't go as I had imagine it would. It was extremely painful to the point that I cried and he had to stop. With time, we both learned what we liked in terms of foreplay. The problem was, that it still continued to be painful. Sex wasn't so often, so maybe that was a reason why it was always painful. We hardly had sex because of this but we still made up for it through oral or other forms. Unfortunately,  years into our relationship he decided to end things so I never really figured out why sex continued to be so painful. Towards the end, I started to realize that the pain was lessening. Instead, there was always a burning sensation and discomfort but I never got pleasure from it. Nothing at all. Has anyone else had this kind of experience? It's very frustrating and it hurts my self esteem because it feels as if something is wrong with me!