To understand who Mary Magdalene was, we need to find the closest or earliest sources about her. But there are no earlier sources about her than the canonical Gospels, which came 40-60 years after Jesus died. Mary is recorded very briefly in several places of the four canonical Gospels (Matt 27:56, 61; 28:1; Mk 15:40, 47; 16:1, 9; Lk 24:10; Jn 19:25; 20:1, 18). In these Gospels, she appears to be a strong follower of Jesus, a witness to his crucifixion, burial, and resurrection. Jesus drove the seven demons from her (Lk 8:1-3; Mk 16:9). Other than the above, we don't have information about her.
For a long time, however, the Western church has colored Mary Magdalene as a sinner and a prostitute, considering the repentant sinner in Luke 7:36-50 as Mary Magdalene. But this reading is baseless.
In the 2nd-3rd-century apocryphal gospels such as the Gospel of Mary or the Gospel of Philip, which are Gnostic-leaning documents, Mary is portrayed differently as a companion of Jesus (Gosp. of Philip) and the one Jesus loved and kissed (Gosp. of Mary). Later, she stood tall as a very influential figure in Gnostic Christianity.
Otherwise, Da Vinci Code's claim that Jesus was married to Mary Magdalene is baseless. There is no historical evidence evincing such a case.