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

Round-Trip Scenario

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.

With the Visual Designer for Telerik Data Access you don’t have to choose whether to forward- or reverse-map your project in advance. Thanks to the round-trip mapping functionality you are able to employ both approaches at any moment during design time. Round-trip mapping is built into the Telerik Data Access Visual Designer. It allows developers to make changes in the database schema, and pull those into their domain model, or update their domain model, and push those changes to the database schema. To leverage round trip mapping, start with either Model First, or Database First mapping. Once you have a model in place, you are free to push and pull changes as needed.

Pulling-In Database Schema Changes

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 Update from Database 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 entity is created and mapped to the database 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.

Starting the Update from Database Wizard

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

  2. The Update from Database Wizard starts. If there is no database connection specified for the domain model, the Setup Database Connection Dialog appears. Specify a connection string to the database and click Next to proceed.

  3. The next screen is the Choose Database Items page. Here you need to specify which items should be updated.

  4. Once you make all necessary selections, click Next to proceed to the main 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. If your database table or column has been modified, then it will be marked with Modify operation. You could select which changes you would like to apply to your domain model.

  5. The final page of the wizard shows a preview of all changes that will be performed to your domain model.

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

Pushing Domain Model Changes to the Database

The Update Database from Model Wizard allows you to generate schema definition script or schema migration script for creating/migrating a database from an existing conceptual model. The wizard allows you to do conceptual modeling first and then to create a database that supports the domain model.

Starting the Update Database from Model Wizard

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

  2. If there is no database connection specified for the domain model, the Setup Database Connection Dialog appears. Specify a connection string to the database and click Next to proceed.

  3. On the next page you have to specify the update strategy and select which database items you want to create/update.

    The Update Database from Model Wizard allows you to use two different update strategies:
    - Create Database - generates data definition language (DDL) for creating a database from an existing conceptual model.
    - Migrate Database - generates data definition language (DDL) for updating(migrating) an existing database.

    If you are doing a model-first scenario and your database does not exist, then you should use the Create Database *option. If your domain model is based on an existing database (database first scenario) and you want to update the database schema, then you should use the *Migrate Database option.

  4. On the Summary page, you could set deployment options, preview and execute the generated DDL script. The "Create script file and execute" option will save a copy of the generated script to the destination folder, and execute the script against the database.

Next Steps

For further reference, check out the following topics: