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

Owned types' changes are not described correctly #27489

Closed
MartinBuna opened this issue Feb 22, 2022 · 1 comment
Closed

Owned types' changes are not described correctly #27489

MartinBuna opened this issue Feb 22, 2022 · 1 comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@MartinBuna
Copy link

Let's have an entity Person with an owned type Address. When I replace the Address in the Person entity with another Address, the change tracker doesn't show any changes that would imply the Address of Person was changed.
The shadow PK FK is unchanged for original Address, too, pointing it to original Person object.

Table splitting (sharing) is used for below example, but the same thing happens when second table is used.

Original change tracker full debug output:

Address {PersonId: 1} Unchanged
  PersonId: 1 PK FK
  City: 'Granada'
  IsOnEarth: 'True'
  Street: 'Cerveza st.'
Person {PersonId: 1} Modified
  PersonId: 1 PK
  Name: 'Peter' Modified
  Address: <not found>

Code to test this: https://github.com/MartinBuna/EfCoreOwnedTypeProblem/blob/main/EfCoreOwnedTypeProblem/Program.cs

I haven't found this in #22954 and I thought it should me mentioned.

@AndriySvyryd
Copy link
Member

@MartinBuna The context doesn't detect changes immediately. To get the view of what SaveChanges will actually see call context.ChangeTracker.DetectChanges() first:

Address (Shared) {PersonId: 1} Added
  PersonId: 1 PK FK
  City: 'London'
  IsOnEarth: 'False'
  Street: 'Downing Street'
Address (Shared) {PersonId: 1} Deleted
  PersonId: 1 PK FK
  City: 'Granada'
  IsOnEarth: 'True'
  Street: 'Cerveza st.'
Person {PersonId: 1} Modified
  PersonId: 1 PK
  Name: 'Peter' Modified
  Address: {PersonId: 1}

@AndriySvyryd AndriySvyryd added closed-no-further-action The issue is closed and no further action is planned. and removed type-enhancement labels Feb 22, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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