OK, this is an awkward situation. Not only has the child been exposed to a new person living in the home, but now knows that this is your boyfriend, and perhaps having him "stay in the basement" is even worse because he's going to like a troll in her mind, an ever present but never seen intruder.
Children, especially girls, are very sensitive at this age. It doesn't matter if the fella doesn't pose a threat. This is an intruder into her personal space (the entire home) and a change to the status quo of people in the home. I'm not surprised that she's reacting this way. Frankly, the best solution is to tell him that it's not working out and he must leave asap. I know you don't want that; you want to help and you're in a relationship with the guy, but this is putting you at risk of losing your daughter because it's the child's perception and comfort which is important here, not the facts. I leave it to you as to whether or not you're going to let him stay. If he does stay, have him spend some time with you and the child. He's not a "new dad", but she needs to understand on a deeply personal level that he's not a threat. And that won't be accomplished by logical arguments. This is about how the child feels.
Children never have the right to determine custody or access in Ontario. It's a very common misconception that at age 12 they get that right, and if I had a nickel every time someone told that to a child...well I wouldn't be working on this website.
Having said that, if this goes to court then the court is going to want to know the child's views and preferences. That will be a piece of evidence, like any other, in determining what's in the child's best interests.
How much weight will the court give to the child's views and preferences? That's the big question, and one that's not easy to answer. It depends on a few factors: the age of the child, the maturity of the child, what the child wants, why the child wants it, and how firmly the child wants it. That's the job of the Office of the Children's Lawyer when they appoint a lawyer or social worker to assist the court. And if this goes to court, the first thing that the judge will do (absent any clear safety factors or obvious reasons why dad should get custody or primary residence) is ask the OCL to look into the matter and report to the court as a neutral third party on behalf of the child. This is no secret and this is what father's lawyer will tell him if that lawyer knows what they are talking about.
By the way, I've been on the OCL panel of lawyers and I've represented plenty of children in court during custody/access disputes, so I know what I'm talking about.
Dad will feel empowered to challenge you on custody or primary residence, and he'll want to believe and exaggerate what the child as told him. Just as you'll want to downplay the child's preferences here because you believe that she's not in any danger. But the child's views and preferences are subject to the child's feelings and view of their own situation.
I've had five year old kids tell me "I want to live with dad because mom's boyfriend beats us up and I'm scared", and although the evidence of a five year old generally doesn't carry a lot of weight this evidence certainly does. And I've had thirteen year old boys tell me "I want to live with dad because he has a hot girlfriend, a pool, a PS4, and lets me stay up as long as I want to". That older child's views and preferences aren't based on anything to do with that child's own best interests and aren't going to carry a lot of weight. So it all depends.
Dad will be told that if he wants to take this to court he has to do it soon before there's a status quo that he'll be deemed to be ok with, and before the child changes her mind about your boyfriend being there. So you need to either boot the boyfriend or start working hard to bring the child around. I recommend the former.
So to answer your question succinctly, yes the judge could take the child's side. Or the judge could decide that the child's views and preferences shouldn't rule the day in this case. It will take months before dad serves you with court papers and gets to make a motion for OCL involvement, and in that time maybe the child will warm up to the basement guy. But you have to ask yourself if you're willing to take that risk.
In answering that question for yourself, you need to have a serious talk with your guy. Is there literally nowhere else he could stay? I doubt he wants to put you at risk of losing the child. Does he have any kind of criminal record? Any other children that he isn't seeing or not paying support for? Any involvement in the past with the Children's Aid Society? This will all come out if it goes to court and you need to know now, 100%. Keep in mind that he has an incentive to lie because I'm sure he likes having a place to stay.
Does that all make sense?