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

Does not insert OwnsOne columns #156

Open
adminnz opened this issue Dec 12, 2023 · 2 comments
Open

Does not insert OwnsOne columns #156

adminnz opened this issue Dec 12, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@adminnz
Copy link

adminnz commented Dec 12, 2023

My postgresql database has:

CREATE TABLE events
(
    ...
    error_details JSONB NULL
    ...
)

In my model i have:

modelBuilder.Entity<Event>().OwnsOne(x => x.ErrorDetails, builder => builder.ToJson("error_details"));

Which when using the ef core Add(..) or Update(..) methods correctly serializes the nested object to json and stored.

But using Upsert(...) the resulting sql does not produce the error_details column.

When i look at the ef core EntityType model, the error_details is not listed in the GetProperties(), so I don't know where it is meant to be fetched from.

@kristian-dam-bori
Copy link

kristian-dam-bori commented Jan 9, 2024

I've also experienced this after using the new .ToJson() EF API.

Worked flawlessly before when using the .HasColumnType("jsonb")

@artiomchi
Copy link
Owner

I took a peek at it, and it looks as the ToJson() columns are treated very differently, almost as a relationship of some kind. To properly handle them, it would be needed to dig deeper into EF Core's code, and pull out the code they use to serialise this data into JSON, as I'm not sure if just passing an object would work, as it did before.

Unfortunately I didn't work with these columns, and don't have the time myself for that deep investigation, but would appreciate any help on this

@artiomchi artiomchi added enhancement New feature or request help wanted Extra attention is needed labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants