I have a schema like this:
* Customers
int ID
string Name
List<Location> Locations
* Locations:
int ID
string Address
string City
string State
string Zip
int CustomerID
So I have a many-to-one relationship between "Locations" and "Customers".
I was hoping that EF would do all the "heavy lifting" for me. I'm using EF navigation, I 'm successfully able to query the "complex record with nested fields" and display it in a Razor page.
The only thing I'm NOT able to do so far is to successfully SAVE my updates to the "nested items". I can SEE my changes in the debugger in OnPost() (at least I see them when I define a separate variable/separate model binding for "Locations"). But I can't figure out how to REPLACE the old values in "Customer.Locations" with the new values in "Locations".
Or better, eliminate the "Locations" variable altogether, and just let the Razor page update the rows and columns in "Customer.Locations" directly.
This link seems relevant: Removing all records from navigation properties in Entity Framework
These are the details of what I've tried so far,and where I'm stuck: ASP.Net Core: How do I update (change/add/remove) nested item objects (One-to-Many relationship)?
Q: Any suggestions? In particular, can anybody point me to any examples? I've searched, to no avail.