Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1674

Clarify documentation for when StringObjectIdGenerator would be used

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: 2.2.4
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows 10 x64, MongoDb 3.2.6

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: