A locked door doesn't stop them if they have the vampire power "Eternally Welcome", but it does if they don't. If you lock the door at night, have tons of garlic around, have your lot set to "Private Dwelling" and own a dog you pretty safe from vampire attacks at home. Each of these aren't a guarantee as dogs wander the neighborhood, "Eternally Welcome" and "Garlic Immunity" vampire powers do exist on NPC vampires, and on rare occasions vamps can show up despite "Private Dwelling" lot trait but to all four precautions to fail at once would take a perfect storm that the odds are extremely long on happening but is theoretically possible.
Or you can use the perfect answer play with a vampire yourself. That last one never fails. It is my go to method, not because I want to prevent said attacks, but because I just love to play as a vampire.
I actually would love a late night vampire visit.
We could spare or train once he/she realized there in no food for him/her at my home as we are already turned. As he/she is likely needing a drink I would even offer him/her a plasma fruit or plasma pack as I always have tons around. But sadly vamps don't tend to drop by other vamps houses for a quick bite. It is the one downside to playing a vamp. Well that and sunlight before you level up enough and invested enough powers to be immune to it.