Create A Order Model
The Order model contains navigation properties to both Customer, OrderLines, and OrderStatus. The current naming convention is understood by both Code First and Dynamic MVC.
Create A OrderStatus Model
The OrderStatus model will be used to track orders throughout the order processing, which starts with "New Order" and ends with "Order Shipped."
Create A OrderLine Model
The OrderLine model links an Order to a Product.
Update The Database With Code First
Create the three DbSet properties in the data context for each new model to the data context. Create a migration with the "add-migration" command. Once the migration is reviewed, update the database using the "update-database" command.
Test Drive Dynamic Pages
Run the application. Navigate to OrderStatus page. Create three new OrderStatus records: New Order, Processing, and Shipped. Navigate to the Orders page. Notice we can filter by OrdersStatus or Customer. Create an Order by clicking the create hyperlink. Notice the OrderLines hyperlink on the orders page for each order record. Click the OrderLines hyperlink. Notice the Order Filter is showing the primary key of the order. Dynamic MVC will look for the first property that contains “Name” or “Description” as the text to display in the drop down. If this cannot be found, it displays the primary key. Although this is functional, it is not very practical. In our next tutorial we will see how we can customize the orders dynamic views.