Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization settings with Cosmos Db Provider #30300

Closed
vafzamora opened this issue Feb 16, 2023 · 2 comments
Closed

Serialization settings with Cosmos Db Provider #30300

vafzamora opened this issue Feb 16, 2023 · 2 comments

Comments

@vafzamora
Copy link

I have a customer who uses this code snippet to change default null value handling behavior for JSON serialization when using the CosmosDb client:

       var cosmosJsonOptions = new JsonSerializerSettings
        {
            NullValueHandling = NullValueHandling.Ignore
        };
        Configure(builder);         
        JsonConvert.DefaultSettings = () =>
        {
            return cosmosJsonOptions;
        };

He asked me on how to do the same for EF Core using CosmosDb provider.
I didn't find a way to set serialization options when configuring the DbContext with UseCosmos, only a subset of CosmosDb options is available.
Reading the source code I could see that the serializer instance used internally is created with JsonSerializer.Create() which, according to Newtonsoft documentation, won't use JsonConvert.DefaultSettings.

Is this by design? Is there any way to change serialization settings for CosmosDb provider?

EF Core version: 6+
Database provider: (e.g. Microsoft.EntityFrameworkCore.Cosmos)

Thanks in advance,

@ajcvickers
Copy link
Contributor

Duplicate of #17306. Please vote (👍) for that issue.

@roji
Copy link
Member

roji commented Feb 18, 2023

Duplicate of #17306

@roji roji marked this as a duplicate of #17306 Feb 18, 2023
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants