Here is an article that quotes Ehrman on the matter of The DaVinci Code and Mary Magdalene.
According to this article, he says much of what is portrayed in the book is purely fiction, and seems to say that a lot of what is in the Gnostic gospels about Jesus & Mary Magdalene is also fiction.
CC&E