‘bdfb4361-93b5-436d-bed2-2e56f3e60351’ is not a valid 24 digit hex string

I encountered this error while working with MongoDB Official C# Driver. This error occured when I was trying you insert some test data into a collection. Here’s the snap of error it shown



Later in the course I figured out i was using BsonReprentation Attribute to decorate the Bson data type as objectId.


When I changed the attribute to BsonId it started working fine. 



Below is my model before and after the changes.



Hope it helps somebody!


Leave a Comment