I was in a similar situation, except I was contributing the deposit (poor credit rating and wasn't married) tried to get a legal document but the mortgage wouldn't allow me to be on the deeds and I couldn't be on the mortgage, the deposit money had to be a gift etc so risky situation.
I insisted we had to be married (the legal bit) before he'd be 'gifted' the deposit and he promised he'd add me to the mortgage deeds once the house was bought. Fast forward, thank god we got married because he then said oh we have to wait 6 months, 6 months later there was another excuse why I couldn't be added.
I registered a matrimonial home rights notice on the property with the land registry which essentially put a notice on the deed that it was a matrimonial home and it prevents a sale or remortgage without consent. Turned out a year later he tried to remortgage in secret to pull out 145k, the bank told him no because of my rights notice, shortly after the marriage fell apart and that rights notice was the only thing that prevented him from selling or remortgaging or kicking me out! (He tried desperately to get me to remove it).
Fast forward to the divorce, he again was desperate to keep it out of court but refused to cooperate with financial disclosure or anything else, and it was a long ordeal because he continued to not cooperate and initially was saying that I should get nothing from the house because I'd contributed nothing and the deposit money was gifted to him. Well the court said no starting point is 50% because it's a matrimonial home. Went all the way to a final hearing but eventually I was able to get an immediate order for sale (what I wanted) with 100% of the equity and cost orders etc.
So the TLDR is - you should be extremely careful and get legal advice if you go into this without being married and 💯 ensure you are legally protected. Getting married (before the house is purchased) is probably the safest thing to do and registering the marital rights notice if you're not added to the deeds (in my case it ended up being an absolute blessing i wasn't added to the mortgage as I'd have been liable for the mortgage payments he stopped paying!) but do be extremely careful about who you're marrying and protecting yourself. Yes I got all of the equity and was able to sell the house but all in all I basically lost a considerable amount of money after the court fees, and it was extremely stressful as well so do look out for yourself, don't just trust anything you're told, people do change.