[CSHARP-465] Can't Change Id Element Name To "Id" Created: 03/May/12  Updated: 20/Mar/14  Resolved: 03/May/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Tim Scott Assignee: Robert Stam
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-464 When Calling SetIdMember, ElementName... Closed

 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".


Generated at Wed Feb 07 21:36:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.