<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:26:53 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[EF-88] Unknown discriminator value &apos;List`1&apos; error</title>
                <link>https://jira.mongodb.org/browse/EF-88</link>
                <project id="22583" key="EF">Entity Framework</project>
                    <description>&lt;p&gt;Thank you for your hard work on implementing this EF Core provider.&#160;&lt;/p&gt;

&lt;p&gt;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.&#160;&lt;/p&gt;

&lt;p&gt;I can write such entities with no problem and they show up in the database as Objects with &quot;_t: List`1&quot; and &quot;_v: Array&quot;. I can also query for them and they return and parse correctly in .NET.&#160;&lt;/p&gt;

&lt;p&gt;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 &quot;Unknown discriminator value &apos;List`1&apos;.&quot;&lt;/p&gt;

&lt;p&gt;I did some searching and found this post: &lt;a href=&quot;https://stackoverflow.com/questions/43312039/unknown-discriminator-value-mongodb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://stackoverflow.com/questions/43312039/unknown-discriminator-value-mongodb&lt;/a&gt; &#160;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;The post (and documentation for the C# driver) suggests to manually map the class map using BsonClassMap.RegisterClassMap&amp;lt;EntityType&amp;gt;(). 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?&#160;&lt;/p&gt;

&lt;p&gt;If this is not supported currently, is there any workaround to avoid needing to do a write first?&lt;/p&gt;</description>
                <environment></environment>
        <key id="2523200">EF-88</key>
            <summary>Unknown discriminator value &apos;List`1&apos; error</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</priority>
                        <status id="11263" iconUrl="https://jira.mongodb.org/images/icons/statuses/generic.png" description="">Scheduled</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="damien.guard@mongodb.com">Damien Guard</assignee>
                                    <reporter username="chris@crucible.ai">Chris Vigorito</reporter>
                        <labels>
                    </labels>
                <created>Tue, 12 Dec 2023 21:40:19 +0000</created>
                <updated>Thu, 4 Jan 2024 17:48:16 +0000</updated>
                                            <version>Public Preview 1</version>
                                                                        <votes>1</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="5984418" author="JIRAUSER1273673" created="Wed, 3 Jan 2024 22:27:12 +0000"  >&lt;p&gt;Customer responded (via email due to permissions issue which is now hopefully fixed, quoting here)&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;Hi Damien,&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;Thanks for the clarification. For this specific issue I wasn&apos;t explicitly trying to use discriminators, but wondering whether it was possible to write .NET collection properties without doing so or via some workaround. It sounds like only pure array types for collections will work for now?&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;I&apos;m attaching a minimal example. If you run the application and call the &quot;write&quot; endpoint once to write an entity to the db, then restart the application and call the read endpoint, it will trigger the error. Everything works properly though if you remove the List&amp;lt;string&amp;gt; property from the entity class and only use array type properties.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;My question was mainly whether, since it works once a write has been made, there&apos;s a way to produce the same behavior without having to call write first.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;For my general use case I will likely need to make use of discriminators and value converters, so it sounds like I&apos;ll need to stick with the C# driver for now. But I will definitely keep an eye out for new releases. I would be great to be able to use the EF Core driver when it&apos;s ready. Is there a rough timeline for the next preview release?&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;Thanks for your help.&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color=&quot;#000000&quot;&gt;Best,&lt;/font&gt;&lt;br/&gt;
&lt;font color=&quot;#000000&quot;&gt;Chris&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;</comment>
                            <comment id="5958131" author="JIRAUSER1273673" created="Mon, 18 Dec 2023 18:21:30 +0000"  >&lt;p&gt;Hi Chris.&lt;/p&gt;

&lt;p&gt;Type discriminator support is not included in the EF provider yet - we&apos;re hoping to get it into the next release.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;p&gt;Damien&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                        <customfield id="customfield_23812" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Assigned Team</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="26445"><![CDATA[Dotnet Drivers]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i2m52s:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        </customfields>
    </item>
</channel>
</rss>