How can serilize Microsoft.EntityFrameworkCore.DbUpdateException with new MongoDB driver version 2.24.0?

23 Views Asked by At

the below class

public class FailedRequestLog
{
    public string Id { get; set; }
    public string Url { get; set; }
    public object Errors{ get; set; }
}


` use to log failed request in MonogDB in .net8 and the error

MongoDB.Bson.BsonSerializationException: 'An error occurred while serializing the Errors property of class MyProject.FailedRequestLog: 
Type Microsoft.EntityFrameworkCore.DbUpdateException is not configured as a type that is allowed to be serialized for this instance of ObjectSerializer.'

raised on Errors field set to DbUpdateException _collection.InsertOneAsync(newEntity) when use MongoDB.Driver Version=2.24.0 . how can serilize Microsoft.EntityFrameworkCore.DbUpdateException with new MongoDB driver version 2.24.0?

it is work in MongoDB Driver Version=2.18.0 .

0

There are 0 best solutions below