Uploaded image for project: 'Entity Framework'
  1. Entity Framework
  2. EF-98

Error when deserializing `IList<string>`: Unknown discriminator value 'List`1'

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 8.0.0
    • Affects Version/s: Public Preview 1
    • None
    • Dotnet Drivers

      Follow the Getting Started example, add a simple List property:
       
      `public IList<string>? TestStringArray { get; set; }`
       
      Serializing works:
       
      ```
      "TestStringArray":

      {     "_t": "List`1",     "_v": [...]   }

      ```
       
      Deserializing fails:
       
      ```
      An exception of type 'MongoDB.Bson.BsonSerializationException' occurred in MongoDB.EntityFrameworkCore.dll but was not handled in user code: 'Unknown discriminator value 'List`1'.'
      at MongoDB.Bson.Serialization.BsonSerializer.LookupActualType(Type nominalType, BsonValue discriminator) at MongoDB.Bson.Serialization.Conventions.StandardDiscriminatorConvention.GetActualType(IBsonReader bsonReader, Type nominalType) at MongoDB.Bson.Serialization.Serializers.DiscriminatedWrapperSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer`1 serializer, BsonDeserializationContext context) at MongoDB.Bson.Serialization.Serializers.EnumerableSerializerBase`2.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context) at MongoDB.Bson.Serialization.BsonSerializationInfo.DeserializeValue(BsonValue value) at MongoDB.EntityFrameworkCore.Serializers.SerializationHelper.ReadElementValue[T](BsonDocument document, BsonSerializationInfo elementSerializationInfo) at MongoDB.EntityFrameworkCore.Query.QueryingEnumerable`2.Enumerator.MoveNextHelper() at MongoDB.EntityFrameworkCore.Query.QueryingEnumerable`2.Enumerator.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
      ```

            Assignee:
            damien.guard@mongodb.com Damien Guard
            Reporter:
            tonyhernandez743@gmail.com Anthony Hernandez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: