This repository was archived by the owner on May 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Set other side of a relationship automatically #11
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
For example:
var person = new Person { FirstName = "Many", LastName = "Test" };
var address1 = new Address { Street = "Many test 1", City = "Saved as a reference" };
var address2 = new Address { Street = "Many test 2", City = "Saved as a reference" };
person.OtherAddresses = new List<Address> { address1, address2 };
Context.People.Add(person);
Context.SaveChanges();
Right now, in the above code snippet there is no navigation property from Address to Person. If one was added to Address it would have to be manually set to the person instance:
var person = new Person { FirstName = "Many", LastName = "Test" };
var address1 = new Address { Street = "Many test 1", City = "Saved as a reference", Person = person };
var address2 = new Address { Street = "Many test 2", City = "Saved as a reference", Person = person };
person.OtherAddresses = new List<Address> { address1, address2 };
Context.People.Add(person);
Context.SaveChanges();
Make this automatic in SaveChanges()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request