Cannot deserialize string from BsonType ObjectId in MongoDb C#

前端 未结 2 1528
误落风尘
误落风尘 2021-02-18 22:31

I am getting error \"Cannot deserialize string from BsonType ObjectId\" while trying to get all the record from MongoDb in C# WebAPI

My Id is



        
2条回答
  •  无人共我
    2021-02-18 23:05

    Instead of using

    ed.Id = Guid.NewGuid().ToString();
    

    I used

    ed.Id = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
    

    For generating Id

    Its working fine : )

提交回复
热议问题