I have been reading several articles and so far I have not been able to understand the real function of navigation property. In the last articles I read, it said it serves as a foreign key for navigation, but when I tried to create a project starting with Model First, the foreign keys did not have the same name as the navigational properties. Another question is about the Create method, in my opinion, this method would have the function of creating the entities if they do not exist in the database, but when I tried to delete one of the entities and test the code, this did not happen. Could anyone clarify these two doubts I still have? Follow the code with the Create method below:
using (var db = new AccountingSystemContainer())
{
var invHeader = db.InvoiceHeaderSet.**Create();**
var invDetail = db.InvoiceDetailSet.**Create();**
invHeader.Total = 150m;
invDetail.ItemDescription = "Algum Item";
invDetail.Price = 75m;
invDetail.Quantity = 2;
invHeader.InvoiceDetail.Add(invDetail);
db.InvoiceHeaderSet.Add(invHeader);
db.SaveChanges();
}