As you might or might not know for some time now we have been working on a tool that would make migrating from Linq2Sql to Telerik OpenAccess a breeze. Yesterday (the 13th of October) we released an internal build including a beta version of the new Telerik OpenAccess Linq to SQL converter.
In a few simple steps I would like to explain both how to use the tool and the capabilities and important considerations you should know about. First of all for the purpose of demonstrating the converter, we will use this simple LINQ to SQL model :
The model contains the following items from the Northwind database:
Before we start converting the L2SModel to Telerik OpenAcces Domain Model, we should get familiar with the following important notes:
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 Domain Model.
The start page of the wizard will appear:
Read the notes and press Next to proceed.
The second page is the place where you need to specify the settings for the conversion.
When all settings are specified, click Next to proceed to the last page of the wizard.
Again several important remarks are pointed out here. Be sure to read them and click Finish to begin the conversion.
Here are some clarifications about the conversion process: once you click the Finish button, the LINQ to SQL model is converted to a Telerik OpenAccess ORM Meta 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 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, a new dialog will appear prompting you that the conversion has completed successfully (or has failed).
You have the option to 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.
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.
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 OpenAccess 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 oa_CategoryInsert_sp 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_CategoryInsert_oa will be used as an insert procedure for the Category object. At this point the sp_CategoryInsert_oa 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.
The beta version of the Telerik OpenAccess LINQ to SQL Converter does not support the following scenarios:
In conclusion, I would like to mention that while it is in a working state this is a beta version of the converter. We are looking forward to any feedback or suggestions you might have on the tool. Also stay tuned for the tomorrow's blog post – Fluent mapping improvements.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required