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

How to: Convert from L2S Model to Telerik® Data Access Domain Model

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 purpose of this tutorial is to show you how to convert LINQ to SQL Model to Telerik Data Access Domain Model, by using the Telerik Data Access LINQ to SQL Converter.

The LINQ to SQL Wizard currently cannot be started for LINQ to SQL models hosted in Web Sites. As a workaround for this limitation, you can move the L2S model to a separate project before converting it to a Telerik Data Access model.

For the purpose of demonstrating the converter, the following simple LINQ to SQL model will be used:

The model contains the following items from the Northwind database:

  • Two tables - Employee and Category.
  • One view - Invoice
  • Three stored procedures - AddCategory, CustOrderHist and CustOrderDetail. The AddCategory function is used as an insert procedure for the Category entity. It was created manually as it is not part of the Northwind database.

Working with the Wizard

Before you start converting the L2S Model to Telerik Data Access Domain Model, you should get familiar with the following important notes:

  • Only buildable projects will be converted – before starting the wizard, a build process of the target project will be performed. If the project build fails, the wizard won’t start and you will be prompted to fix the compilation errors first.
  • If the project is under source control, it will be checked out automatically during the conversion. Be sure that the source control plug-in is active and no files are exclusively checked out by another user.
  • Invalid dbml files won’t be converted. If your dbml file is invalid and contains invalid data it will not be processed by the wizard.
  • Before starting the conversion, a backup of the project's original state will be created.

All other important characteristics of the wizard will be mentioned later in the topic.

Starting the Wizard

In order the start the L2SConversion wizard, select the target dbml file in Solution Explorer, right-click and select the Convert from L2S Model to Telerik Data Access Model.

Alternatively, you could use the Telerik -> Telerik Data Access -> Convert LINQ To SQL Model menu command.

The start page of the wizard will appear:

It describes all important notes discussed in the previous section. Read the notes and press Next to proceed. The second page is the place where you need to specify the settings for the conversion.

Use the default settings and click Next to proceed to the last page of the wizard. For more information about the Specify Conversion Settings dialog, read here.

Again several important remarks are pointed here. Be sure to read them and click Finish to begin the veritable conversion.

Here are some clarifications about the conversion process: once you click the Finish button, the LINQ to SQL model will be converted to a Telerik Data Access Domain Model. If the conversion has completed successfully the wizard creates a backup of the original state of your project. Next, the converted domain model is saved as a RLINQ file to the specified directory, it is then included in your project. The wizard will update the project references and will add references to the necessary assemblies. Last but not least, the required connection string will be added to the project configuration file. As soon as these actions are executed, new dialog will appear prompting you that conversion has completed successfully (or has failed). You could review the conversion log when the wizard is closed. The last step is to open the generated RLINQ file and to press the Ctrl+S (File -> Save) command to generate the entities.

Reading the Conversion Log

During the conversion each important action is written in a log file. Once the conversion has completed you have the option to open the log file. Of course, you can do that on a later stage. The log file is saved in the root directory of your project with name "L2SConversionLog.xml". Be sure that you open the report file with Internet Explorer.

The output of the conversion log is a XML document. That document, with the combination of XSLT template is transformed into easily readable report containing detail information about the conversion. When you want to open the log, be sure you open it with Internet Explorer.

Converting CRUD Stored Procedures

In the basic LINQ to SQL model used in this example, the AddCategory stored procedure is used as an insert procedure for the Category table. Due to the specific naming conventions used in Telerik Data Access Domain Model, the AddCategory function cannot be used as an insert procedure in the converted domain model. For that reason the L2SConverter will create an additional stored procedure named sp_oa_ins_category and will add it in the domain model.

Note that the original AddCategory stored procedure will be converted, too. However, in the converted domain model, sp_oa_ins_category will be used as an insert procedure for the Category object. At this point the sp_oa_ins_category exists in the domain model, however, it does not exist in the database. The last step you need to perform in order to use the converted domain model at run time, is to create the corresponding procedure at the server. You can do that manually, or you can use the Update Database from Model Wizard. For more information, please refer to How to: Map CUD Operations to Stored Procedures.

Specific and Not Supported Cases

Specific cases:

  • Converting many-to-many relationships – in LINQ to SQL the many-to-many relationships are represented with three tables – or in other words three entities are created. While in Telerik Data Access Domain Model, the join table is not represented in the Visual Designer and an entity for that table is not created. In order to keep compatibility between the models, the L2S converter will convert the relationship as it is. That means, three tables will be added in the converted domain model.

Next Steps

For additional information, check out the following links:

The following topics provide UI reference of the LINQ to SQL Conversion Wizard: