Inserting and Updating Data

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This is the final task of the Entity Framework Quickstart. In this task, you will save changes made to Course objects bound to the DataGridView control to the database. You will also run the completed Course Manager application.

  1. In the Toolbox, expand Common Controls, drag the Button control to the CourseViewer form designer, change the name of the control to saveChanges, and change the Text value to Update.

  2. In the CourseViewer form designer, double-click the saveChanges control.

    This creates the saveChanges_Click event handler method.

  3. Paste the following code that saves object changes to the database.

  • In the closeForm_Click event handler method, type the following code. This code disposes of the object context before the form is closed.

  1. From the Debug menu, select Start Debugging or Start Without Debugging.

    This builds and starts the application.

  2. When the form loads, select a department from the ComboBox control.

    This displays the courses that belong to that department.

  3. In the DataGridView, update course information or add a new course and then click Update.

    This saves changes to the database and displays a message box to indicate that changes have been saved.

You have successfully created and run the Course Manager application. You have also completed this Entity Framework quickstart.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft