-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: Public Preview 1
-
None
Thank you for your hard work on implementing this EF Core provider.
I am attempting to use it within an ASP.NET Core application and running into an issue when entities have a List (or any ICollection) property.
I can write such entities with no problem and they show up in the database as Objects with "_t: List`1" and "_v: Array". I can also query for them and they return and parse correctly in .NET.
However, if I attempt to query for them without having written one such entity to the collection since application start, then I receive the error "Unknown discriminator value 'List`1'."
I did some searching and found this post: https://stackoverflow.com/questions/43312039/unknown-discriminator-value-mongodb
It suggests the issue is that the class must be mapped in the Bson class map before the first read occurs. When an entity is written, this class map is created under the hood, which is why it works after a write.
The post (and documentation for the C# driver) suggests to manually map the class map using BsonClassMap.RegisterClassMap<EntityType>(). However, I tried putting this in my startup code and I still see the error. Should this approach work with the EF Core provider, or is there another way to do this?
If this is not supported currently, is there any workaround to avoid needing to do a write first?