title: MongoDB BsonSerializer.Deserialize and F#
body: <p>The following snippet appears to serialize the record properly, but the deserialization sets the fields to their default values.</p>
  
  <pre><code>open MongoDB.Bson
  open MongoDB.Bson.Serialization
  open System
  
  module BsonIssue = 
  
      type MyData =
          { 
              Id : ObjectId
              Time : DateTime
          }
  
      let serialize(data : MyData) =
          let doc = BsonDocument()
          BsonSerializer.Serialize&lt;MyData&gt;(new IO.BsonDocumentWriter(doc), data)
          doc
  
      let deserialize(doc : BsonDocument) =
          printfn "Attempting to deserialize %A" doc
          BsonSerializer.Deserialize&lt;MyData&gt;(doc)
  
      let data = { Id = ObjectId.GenerateNewId(); Time = DateTime.Now }
      printfn "The data: %A" data
      let serialized = serialize data
      printfn "After serialization: %A" serialized
      let deserialized = deserialize serialized
      printfn "After deserialization: %A" deserialized
  </code></pre>
  
  <p>Here is an example of the output:</p>
  
  <p>The data:</p>
  
  <pre><code>{Id = 55de887754893731fceeef58;
   Time = 8/26/2015 11:48:07 PM;}
  After serialization: seq [_t=MyData; _id=55de887754893731fceeef58; Time=2015-08-27T03:48:07.836Z]
  Attempting to deserialize seq [_t=MyData; _id=55de887754893731fceeef58; Time=2015-08-27T03:48:07.836Z]
  After deserialization: {Id = 000000000000000000000000;
   Time = 1/1/0001 12:00:00 AM;}
  </code></pre>
  
  <p>Thanks in advance.</p>