I have an Apple entity where it contains an incrementing identity field.
Owner owner = new Owner();
Apple apple = new Apple();
DbContext.Apple.Add(apple);
Owner.Apple = apple;
DbContext.Owner.Add(owner);
DbContext.SaveChanges();
Would the above code correctly link two entities together while both inserting into the database?
I’m guessing this has something to do with Delayed Execution, but I am still very blurred on this concept.
You can assign the Apple to your owner, insert the owner in your database, and then they will both get inserted (with a relationship between the two).
So just like this: