Dentist while pregnant

Is it safe to go to the dentist

Im having pain on one of my tooths but i know im probably going to need an xray is that safe or not? 27 Weeks pregnant