He knows I’m married and still wants me

TLDR
I've watched this exact scenario play out dozens of times, and the part nobody says out loud is that being pursued while married feels *good* before it feels bad. The real decision isn't whether you'll sleep with this person - it's whether you'll keep the channel open. Here's how I'd handle it, practically, without the sermon.
Why does the pursuit work when they already know you're married?
Because they're not really targeting you - they're targeting a gap. Someone who knows you're married and pushes forward isn't confused about your situation; they've decided the situation is negotiable. Sometimes that's delusion, sometimes it's competitive, sometimes it's just careless entitlement. Either way, the flattery lands because wanting someone else to want you is a universal hunger, especially a few years into a marriage when feeling *chosen* daily gets replaced by routine. You're not weak for enjoying the attention. You're a person getting a dopamine hit from proof that you're still attractive to someone other than the person who knows your laundry schedule. But notice the reframe: every message you answer is emotional real estate taken from your actual relationship. You don't have to be in bed with anyone to already be paying rent on this. The flirty banter *is* the cost. It's already the thing.
What do you actually do about it?
Send one clear boundary, once, without softness that reads as a door left ajar. Ambiguity - "we probably shouldn't be texting like this, haha" - is an invitation dressed as a limit. At work: "I'm married, I'm not interested, and I need us to keep things professional." In a friendship: "I value the friendship, but the flirting has to stop completely or the friendship does too." With an ex: block first, explain never. If they persist after one clean statement, stop narrating and start escalating - save the messages, screenshots, dates. That's not drama preparation, it's just evidence in case you need HR or a mutual friend to lean on the pressure. Be prepared that it might get awkward or even hostile. A clean boundary doesn't guarantee a graceful exit. Sometimes the person who "just liked you" gets cold or retaliatory when refused. That's information about them, not a problem with your boundary.
And tell your spouse. Not as a confession of a crime - you haven't done one - but as a pre-emptive defusal of a secret. Secrecy is the actual threshold of infidelity, not the physical line everyone jokes about. Something like: "Someone's been pursuing me, I've shut it down, and I'm telling you because I don't want any part of my life with you to happen behind your back." Framed that way, it's a statement about your loyalty, not a test of your spouse's reaction. The people who get blindsided later almost always told themselves they were protecting the marriage. You'd be protecting it now, while it still counts.
What is this attention actually filling?
Here's the part worth sitting with after the boundary is set: the pursuer didn't create the vulnerability, they found it. Ask yourself honestly - what is this attention feeding that my life isn't? Feeling unseen? Feeling unsexy? Feeling like the interesting version of you is buried under logistics? Some of it is normal marriage fatigue, fixable at home with a real conversation. Some of it is a self-image problem, fixable with things that have nothing to do with a married person's inbox. But whatever you do, don't engage "just a little" to keep the ego boost. The math never works. The emotional bill, the awkward fallout, the thing you'd have to hide - those costs always show up. Better to route the hunger somewhere that costs you nothing, and take whatever remains home to the person who actually knows you.