I'm so sorry. What an awful thing to happen, and especially when you have got as far as 12 weeks.
There is plenty of hope for you. Most women who have a miscarriage are not at increased risk for their next pregnancy. It won't affect your fertility and you can start trying once you have your next period after the operation (some people choose to start straight away but you may want to give your body the chance to recover). Most times, the next pregnancy is successful.
Miscarriage isn't rare. One in five pregnancies miscarries during the first trimester. This number doesn't even include very early chemical pregnancies when the woman probably doesn't know she is pregnant. It is more rare to get as far as the 12 week scan as often your body has taken care of it naturally by then.
I'm sorry you are having to go through with this. Good luck with your operation. I wish you a speedy recovery and I hope you will be back here in a few months time. Do look after yourself and take some time to grieve your loss. You will feel very sad for a while but it will start to get better soon, although you do not ever forget it.