Question: Extra 24-1 Use the Entity Framework to create an Order Options Maintenance application In this exercise, youll use the Entity Framework to create an application

Extra 24-1 Use the Entity Framework to create an Order Options Maintenance application In this exercise, youll use the Entity Framework to create an application that lets you update the data in a table of order options. The OrderOptions table is one of the tables in a database named MMABooksEF. This database is identical to the MMABooks database that was used in the book applications, the book exercises, and these extra exercises except that a primary key has been added to the OrderOptions table so you can update it using EF. Open the project and create the Entity Data Model

1. Open the OrderOptionsMaintenance project in the OrderOptionsMaintenance directory. This project contains the Order Options Maintenance form, along with the MMABooksEF database that contains the OrderOptions table, a Validator class, and code for validating the data the user enters and catching exceptions.

2. Use the Entity Data Model Wizard to create an Entity Data Model that contains just the OrderOptions table in the MMABooksEF database. Write the code to retrieve and update the options

3. Declare two module-level variables: one that stores an instance of the object context for the Entity Data Model and one for an OrderOption object that will be used to store the results of the query that retrieves the data from the OrderOptions table.

4. In the Load event handler for the form, code a query expression that uses LINQ to Entities to get the data from the OrderOptions table. Because this table contains a single row, you should use the Single method on the query. Assign the result to the OrderOption object that you defined in step 2. Then, assign the properties of the OrderOption object to the text boxes on the form.

5. Within the Try block in the Click event handler for the Save button, assign the current values in the text boxes to the properties of the OrderOption object. Then, save the changes to the database and display a message indicating that the order options have been updated.

6. Test the application to be sure it works.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!