View the app for houses and paintings. An entity with a name Househas a ratio of 1: n to HousePicture.
The application allows the user to create and edit House, as well as add / remove HousePictures.
[HttpPost]
public ActionMethod Edit(House h)
{
House original = db.Houses.SingleOrDefault(x=>x.ID==h.ID);
UpdateModel(original);
original.HousePictures = GatherPicturesFromForm();
db.SaveChanges();
}
How are you going to update - add new and delete - the child collection when you recreate the child collection from scratch?
Add()or Attach()for each child in the collection?- In what sequence do you need to add or bind a parent to a child collection?
- , ? EF4, , ?
HousePicture == 0. SQL Server, - PK int IDENTITY(1,1). , EF4 , 2+ .
Entity Framework 4?
- 1: n //?