title: MongoDB: automatically generated IDs are zeroes
body: <p>I'm using MongoDB and official C# driver 0.9</p>
  
  <p>I'm just checking how embedding simple documents works.</p>
  
  <p>There are 2 easy classes:</p>
  
  <pre><code>public class User
  {
      public ObjectId _id { get; set; }
      public string Name { get; set; }
      public IEnumerable&lt;Address&gt; Addresses { get;set; }
  }
  
  public class Address
  {
      public ObjectId _id { get; set; }
      public string Street { get; set; }
      public string House { get; set; }
  }
  </code></pre>
  
  <p>I create a new user:</p>
  
  <pre><code>var user = new User
  {
      Name = "Sam",
      Addresses = (new Address[] { new Address { House = "BIGHOUSE", Street = "BIGSTREET" } })
  };
  
  collection.Insert(user.ToBsonDocument());
  </code></pre>
  
  <p>The user is successfully saved, so is his address.</p>
  
  <p>After typing</p>
  
  <pre><code>db.users.find()
  </code></pre>
  
  <p>in MongoDB shell, I got the following result:</p>
  
  <pre><code>{ "_id" : ObjectId("4e572f2a3a6c471d3868b81d"), "Name" : "Sam",  "Addresses" : [
          {
                  "_id" : ObjectId("000000000000000000000000"),
                  "Street" : "BIGSTREET",
                  "House" : "BIGHOUSE"
          }
  ] }
  </code></pre>
  
  <p>Why is address'  object id 0?</p>
  
  <p>Doing queries with the address works though:</p>
  
  <pre><code>collection.FindOne(Query.EQ("Addresses.Street", streetName));
  </code></pre>
  
  <p>It returns the user "Sam".</p>