Database Reference
In-Depth Information
Figure 5-30. Checking the Include foreign key columns in the model check box will create foreign key associations for
database relationships that are not many-to-many
2.
Use the code in Listing 5-37 to demonstrate the ways in which a foreign key association
can be modified.
Listing 5-37. Demonstrating the Ways in Which a Foreign Key Association Can Be Modified
using (var context = new EFRecipesEntities())
{
var client1 = new Client { Name = "Karen Standfield", ClientId = 1 };
var invoice1 = new Invoice { InvoiceDate = DateTime.Parse("4/1/10"), Amount = 29.95M };
var invoice2 = new Invoice { InvoiceDate = DateTime.Parse("4/2/10"), Amount = 49.95M };
var invoice3 = new Invoice { InvoiceDate = DateTime.Parse("4/3/10"), Amount = 102.95M };
var invoice4 = new Invoice { InvoiceDate = DateTime.Parse("4/4/10"), Amount = 45.99M };
// add the invoice to the client's collection
client1.Invoices.Add(invoice1);
Search WWH ::




Custom Search