You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add code that creates a new instance of SomeEntity and calls SaveChanges() to persist it to the database.
Add code that reads SomeEntity back (on a different instance of DbContext), updates it as follows someEntity.Customer.Age = <different_number_from_what_it_currently_is>, and calls SaveChanges().
The expected outcome is that customer age will be updated in the DB, but actually no change happens. Looking at the entities in the ChangeTracker, I can see that SomeEntity is being tracked as Unchanged. I guess this is understandable - for EF to pick up the change, one of the SomeEntity instance properties needs to change. E.g. this produces the desired result: someEntity.Customer = new Customer { Age = <new_value>, <set all other props to old values>}.
Is there a way to make EF behave as expected? If not, it would be good to talk about this behaviour on the page I linked above.
The text was updated successfully, but these errors were encountered:
Version 8.0 of the provider introduced support for the standard EF ToJson() support, which is generally better than Npgsql's traditional POCO mapping; as a result, the latter is now discouraged (see the 8.0 release notes, as well as the updated JSON docs).
Note that DOM mapping (via JsonDocument/JsonElement) may still make sense in some scenarios, and performing full change-tracking there is tracked by #3314.
Steps to reproduce:
SomeEntity
entity as described on this page https://www.npgsql.org/efcore/mapping/json.html#poco-mapping in thePOCO mapping
section.SomeEntity
and callsSaveChanges()
to persist it to the database.SomeEntity
back (on a different instance of DbContext), updates it as followssomeEntity.Customer.Age = <different_number_from_what_it_currently_is>
, and callsSaveChanges()
.The expected outcome is that customer age will be updated in the DB, but actually no change happens. Looking at the entities in the
ChangeTracker
, I can see thatSomeEntity
is being tracked asUnchanged
. I guess this is understandable - for EF to pick up the change, one of theSomeEntity
instance properties needs to change. E.g. this produces the desired result:someEntity.Customer = new Customer { Age = <new_value>, <set all other props to old values>}
.Is there a way to make EF behave as expected? If not, it would be good to talk about this behaviour on the page I linked above.
The text was updated successfully, but these errors were encountered: