I have a table with books and a table with authors created by model-first. There's a navigation property in Books table pointing to AuthorID (because each book has an author) here i'm trying to fill in the tables with values and it's okay when it comes down to scalar properties. But how to add a value to navigation property? My navigation property is called AuthorBook
Book book1 = new Book();
Author author1 = new Author();
author1.Surname = "Dickens";
author1.Name = "Charles";
db.AuthorSet.Add(author1);`
hbook1.Title = "Great Expectations";
book1.Genre = "Novel"
db.BookSet.Add(book1);
db.SaveChanges();
'
try something like this:
that obviously goes before
SaveChanges();