[EF-88] Unknown discriminator value 'List`1' error Created: 12/Dec/23 Updated: 04/Jan/24 |
|
| Status: | Scheduled |
| Project: | Entity Framework |
| Component/s: | None |
| Affects Version/s: | Public Preview 1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Unknown |
| Reporter: | Chris Vigorito | Assignee: | Damien Guard |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
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? |
| Comments |
| Comment by Damien Guard [ 03/Jan/24 ] |
|
Customer responded (via email due to permissions issue which is now hopefully fixed, quoting here)
|
| Comment by Damien Guard [ 18/Dec/23 ] |
|
Hi Chris. Type discriminator support is not included in the EF provider yet - we're hoping to get it into the next release. Additionally similar functionality that the C# Driver provides - such as discriminators and Class Maps are not supported when using the EF provider as many of these features fundamentally provide the same features in radically different ways. Did you intend to actually use type discriminators? If not could you please provide a minimal repro so I can further investigate as to what might be causing the issue. Thanks Damien |