Embedded id Field Converts to _id

I have a Microsoft Teams document that looks like this:


There is an id field nested in the TeamsCallDetails node. I would like to keep it as “id”, but the .Net API converts it to “_id”, even though I already have a document “_id”. Is there a way to override this?

Here is the poco class for the embedded node:

public class TeamsCallDetails
    public IEnumerable<string> Modalities { get; set; }

    public string Id { get; set; }

Apologies for the formatting:


Hey @John_Boldt ,

try this:

        BsonClassMap.RegisterClassMap<TeamsCallDetails>(m =>
            m.UnmapMember(m => m.Id);
            m.MapMember(m => m.Id).SetElementName("Id");
        var client = new MongoClient();
        var db = client.GetDatabase("db");
        var coll = db.GetCollection<TeamsCallDetails>("coll");
        coll.InsertOne(new TeamsCallDetails());
1 Like

@Dmitry_Lukyanov thank you sir - worked like a champ!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.