System.InvalidOperationException: 'The type 'HashSet<string>' cannot be used as a primitive collection because it is not an array and does not implement 'IList<string>'. Collections of primitive types must be arrays or ordered lists.'
Does the Mongo EF provider support HasConversion? How can I go about troubleshooting this?
While we do support HasConversion for primitive types we don’t (yet) support it for primitive collections. This looks like an oversight as we didn’t have an open ticket for it.
I thought originally it would work because my test on EF8 Comos worked just enough to load and save data without throwing but I suspect that was more luck than intent.
Collections in EF are a bit more involved that regular types given that EF needs to snapshot and compare them for the whole change-tracking etc. That happens up at CLR level not at the DB conversion level so it knows nothing about the types you’re trying to map from up there. Not to mention that even if it did support it you’d never be able to do things like .Where(d => d.Additions.Count > 0) as Count can never be translated as it’s a property on an “unknown” CLR type.
I don’t have any insight into the EF teams priorities but I suspect this is quite a large request with at-best a rough experience. It might be easier for them (or perhaps us) to just natively support HashSet.