Reputation: 856
I've got class like that:
class City
{
long CityId {get;set;}
string Name {get;set;}
List<House> Houses {get;set;}
}
with filled List<House>
with some Houses objects and I want to add City
to db with db.Cities.Add(someCity)
.
Is Houses
also will be added automatically in that moment?
What I need to do to add also Houses
automatically, assuming that my Navigation Properties are set up properly?
Upvotes: 0
Views: 34
Reputation: 1719
Yes, they will, but take into account that if you do it this way, new House
entries will be created in the table. If you want to associate existing houses you will need to add an entity retrieved from database.
Upvotes: 1