Skip to content
New issue

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

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

Already on GitHub? # to your account

efcore 7 - json mapping to non-efcore updated column #29591

Closed
vigouredelaruse opened this issue Nov 16, 2022 · 2 comments
Closed

efcore 7 - json mapping to non-efcore updated column #29591

vigouredelaruse opened this issue Nov 16, 2022 · 2 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@vigouredelaruse
Copy link

vigouredelaruse commented Nov 16, 2022

Ask a question

my understanding of json support in efcore 7

  • materialize entities in the database with mapped properties stored as db provider specific json

what i'd like to do is

  • ingest arbitrary json and store it in a column without using necessarily efcore, in dbprovider native json column
  • use efcore to map pocos to entities in db provider native json column

in other words the use case calls for some non-efcore process to acquire and persist json, presumably in a manner amenable to subsequent consumption by a efcore 7 dbcontext

in the scenario, the 'json ingestion, persist to db' workflow is assumed not to have access to poco clr types, and an asssociated dbcontext

please advise

@maumar
Copy link
Contributor

maumar commented Nov 17, 2022

You can store JSON in a database column using whatever means you like, doesn't have to be thru EF. EF expects it to be in a certain format - we store it very close to how System.Text.Json.JsonSerializer does it with it's default settings - the only difference is that EF stores enum values as strings, rather than ints.

We plan to add customizable serialization options in the future (tracked here: #28043)

But even currently you should be able to serialize an object using JsonSerializer (or manually craft the JSON string, or whatever), store it a JSON column in SQL Server using your preferred method, then configure EF model to map a POCO structure to that JSON column and proceed from there as if you've done everything using EF from the start.

@vigouredelaruse
Copy link
Author

thanks for the clarification. also i prefer to reason over string enums in debugging scenarios

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
@ajcvickers ajcvickers added the closed-no-further-action The issue is closed and no further action is planned. label Nov 17, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants