Database Reference
In-Depth Information
Figure 8-1. A database model for customers and their orders
To create an Entity Framework model based on the database tables in Figure 8-1 , and using the POCO classes
generated by Entity Framework representing an Order, OrderDetail, Customer, and Product, follow the steps below:
1.
Right-click your project, and select Add New Item.
2.
From the Visual C# Items Data templates, select ADO.NET Entity Data Model.
3.
Select Generate from database to create the model from our existing tables.
4.
Select the Order, OrderDetail, Customer, and Product tables, and click Next. In the
generated model, the Product entity has an OrderDetails navigation property for all of
the order details associated with this product. This is unnecessary here, so delete this
navigation property. The completed model is shown in Figure 8-2 .
 
Search WWH ::




Custom Search