C# mongodb BsonElement mapping not working as expected

Hi All,

I am facing issue related to element name in mongo collection. My class declaration is

public class Template : MongoModel, ITemplate
        public string Name { get; set; }
        public string Key { get; set; }

        public string Description { get; set; }
        public long PageSize { get; set; }
        public List<FieldGroup> Groups { get; set; }
        public string EntityGuid { get; set; }
        public bool IsSystemTemplate { get; set; }

        public bool HasCustomTemplate { get; set; }

        public List<ITemplateCommand> CollectionCommands { get; set; }
        public List<ITemplateCommand> EditorCommand { get; set; }

As you can see i have assigned BsonElement to all properties. But when I save the document i am seeing property names, instead it should take values from BsonElement attribute. For some strange reason it is working for embedded document but not main document.

I wrote a extension method to register the call mapping and calling that from Start of application.

BsonClassMap.RegisterClassMap<Template>(opt =>

I am using Mongodb 4.2.1 community and c# driver version is 2.10.4

I want to know why [BsonElement] attribute is not honored.

This is how records look in compass

same issue here (I have class with bselements that do not work in external classlib). have you resolved the issue?