Data Access has been discontinued. Please refer to this page for more information.

How to: Update a Model from an Existing Database

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

The Telerik Data Access Visual Designer uses the Update from Database Wizard to update a domain model for changes made to the database. The Update from Database Wizard overwrites the domain model when updating the data model based on the database changes. The wizard also makes some changes to the conceptual model and mappings, but it only makes these changes when objects are added or modified in the database. For example, new types are added to the model when tables are added to the database, and new properties are added to types when columns are added to a table.

The Update from Database Wizard does the following:

  • If an object has been added to the database (or was not included in the previous model), you can choose to add the object to the model. The relational part of the domain model is updated with the newly-added object. In the case of a table or view (but not a stored procedure), a corresponding type is created and mapped to the object.
  • If an object has been updated, the wizard updates the object definition in the storage model. If any new columns have been added to a table or a view, the corresponding types are updated with matching properties.
  • If tables/views have been deleted from the database, the wizard won't delete the corresponding entities from the domain model. In this case, you have to remove the entities manually.

How to Update a Domain Model when the Database Changes

This section will make a quick overview of the wizard and will guide you through the different steps.

  1. Open the Visual Designer, right-click on an empty area and select Update from Database.

  2. If there is no database connection specified for the domain model, the Setup Database Connection Dialog appears. Here you need to specify a connection to your database. If you have previously created connections they will show up in the list. The next image shows this step in the wizard.

  3. When you have already specified the connection, click next to display the Choose Database Items page of the wizard. Here you need to specify which items (tables,views or stored procedures) should be updated.

  4. Once you make all necessary selections, click Next to proceed to the third page of the wizard.

    Here you could see all changes that will be made to the domain model. If you are adding a new table (column) to the domain model, then the operation for the corresponding table (column) in the wizard is Add. For example, on the previous image, the Orders table is marked as Add. This means that the Orders table does not exist in the domain model. Respectively, it will be added and the corresponding persistent class will be created. If your database table or column has been modified, then it will be marked with Modify operation.

    If an item is deleted from the database, you have to delete it manually in the Visual Designer. This will be demonstrated later.

  5. When you click Next, you will have a preview of all changes that will be performed to your domain model.

  6. Once you are ready, click Finish to commit the changes.

Next Steps

For a complete UI reference of the Update from Database wizard, read here.

For more examples demonstrating how to handle database schema changes, read the Handling Database Schema Changes topic.