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

one to many relationship - PersonID and Person fields are not updated in Child #234

Open
orit1 opened this issue Oct 30, 2019 · 4 comments
Labels

Comments

@orit1
Copy link

orit1 commented Oct 30, 2019

hi,
I have a Person class
Person is a parent of an Address, the relation is one to many (parent has many Addresses)
like that (taken from the constructor of Person):
Addresses = new ChangeTrackingCollection

();

I need when I add Address to person like that:
addresses .Add(new Address())
the properties Person and PersonID in Address getting values according to the Person

how can I do this?
do I need to used with Parent field from ChangeTrackingCollection class? If so how?

Thanks in advance

@tonysneed
Copy link
Collaborator

@orit1, Thanks for the question. You don't have to populate these fields on the client. They will be populated by EF on the server when the entity is saved.

@orit1
Copy link
Author

orit1 commented Oct 30, 2019

thanks for your response
in our system is needed, Is there a nice way to do that?

@orit1
Copy link
Author

orit1 commented Oct 31, 2019

Another important thing -
If I work connect, the fields get values on the server like you said
But if I'm working dissconnect also on the server it doesn't happen
Is there a way to work dissconnect and that the fields fill up?

@tonysneed
Copy link
Collaborator

I see now. In order to populate related fields (foreign keys, reference properties), you will need to do this yourself for disconnected entities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants