title: How to Clone/Copy a POCO Entity for MongoDB with BsonSerializer in the C# Driver
body: <p>What's the best way to make a new copy of a MongoDB POCO entity using the official C# driver?</p>
  
  <p>I've tried this;</p>
  
  <pre><code>    public T Clone()
      {
          var bsonWriter = new BsonDocumentWriter(new BsonDocument(), BsonDocumentWriterSettings.Defaults);
          BsonSerializer.Serialize(bsonWriter, this);
          var newDoc = bsonWriter.ToBsonDocument(typeof(T));
          var e = BsonSerializer.Deserialize(newDoc , typeof(T));
          return e as T;
  
      }//Clone()
  </code></pre>
  
  <p>But all I get is an empty object full of nulls. The POCO object does NOT inherit from BsonDocument by the way, but it does serialize fine and I want to capitalise on all the Bson Attributes it's decorated with, which is why I don't want to copy it some other way. I want a copy as the DB Driver would do it.</p>