This error message occurs when getting the data from MongoDB. The format is yyyy-MM-dd HH:mm:ss.
An error occurred while deserializing the UploadTime property of class UserFile: String '2022-07-25 15:49:18' was not recognized as a valid DateTime.
public class UserFile
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
[BsonElement("_id")]
public string? Id { get; set; }
[BsonElement("upload_time")]
[BsonDateTimeOptions(Kind = DateTimeKind.Unspecified, Representation = BsonType.String)]
public DateTime UploadTime { get; set; }
[BsonElement("data")]
public BsonDocument? Data{ get; set; }
}
How to correctly deserialize date time string? I cannot change the value while insertion because that value is from another application.