-
Type:
Task
-
Resolution: Duplicate
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 2.2.4
-
Component/s: Documentation, Serialization
-
Environment:Windows 10 x64, MongoDb 3.2.6
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I am trying to follow simple steps in the C# driver Quick start but I am hitting a major road block because the driver won't create an ID for my Id public property.
If I understand the docs correctly the driver should use the StringIdGenerator to generate an ID for my
public string Id
{ get; set; }property on my models.
I posted a question on SO about this:
http://stackoverflow.com/questions/37361002/mongodb-2-0-c-sharp-driver-not-creating-id-on-inserts
Since I posted the question I also attached [BsonId] attribute to the property if that would made any difference but it still resulted in null ID being used with InsertOne() which at the 2nd retry results in
A bulk write operation resulted in one or more errors.
E11000 duplicate key error collection: testdb.Customer index: id dup key: { : null }
(obviously).
I also tried registering a class map simply with
BsonClassMap.RegisterClassMap<Customer>();
and it still would not create a value for the Id property.