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

Can't Change Id Element Name To "Id"

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      My Saves are not working. Mongo says I am trying to insert a document with a duplicate key. I think it's because my objects are serializing with key of "_id" instead of "Id". So I map this like this:

      BsonClassMap.RegisterClassMap<Foo>(x => {
      x.AutoMap();
      var memberMap = x.GetMemberMap(c => c.Id)
      .SetIdGenerator(CombGuidGenerator.Instance)
      .SetRepresentation(BsonType.String);;
      x.SetIdMember(memberMap);
      x.IdMemberMap.SetElementName("Id");
      });

      By my documents still serialize with "_id".

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            timscott Tim Scott
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: