Be explicit
I've had this problem a few times, and my choice was always to make it completely explicit. By this I mean stating "I have a partner and nothing romantic os inis on the table". Of course, don't say this in an accusatory tone, just as matter-of-factly as you can.
It is possible that this may make certain people lose interest in trying to befriend you. I believe as long as you don't make a big deal out of this, the only people who would feel alienated are those that would just pursue a friendship as a means to reach a romantic relationship, which is something that you wouldn't want anyways in this situation. A phrasing I've employed in the past (on which I got no negative feedback) would translate as:
Hey, X, I've really enjoyed talking with you, and would like to treat you to coffee and get to know each other better. Just to avoid misunderstandings, I have a partner and no interest in other romantic relationships.
While some people I've said this to have seemed surprised at the abruptness, none seem to have felt alienated, and no misunderstandings have appeared down the line. Just avoid repeating it unless necessary, since after the first time insistence could be interpreted as aggressive or self-affirming.