Now that Linq-to-SQL is not going to be developed any more, it seems developers are left with little choice as to what ORM to use for their next projects. The ADO.NET Entity Framework seems to have become the ORM of choice for most Microsoft developers, who want to address the impedance mismatch across various data representations, but although very good and quite powerful, it falls short on some important characteristics of modern-day development:
- Visual Mapper/Entity Designer with advanced capabilities;
- Lack of native support for databases different from SQL Server;
- Release cycle of 2-4 years;
- Advanced/dedicated technical support;
- No built-in caching layer;
We are sure that code-first developers appreciate the power of EF, but we strongly believe that solving the impedance mismatch should not be the sole reason to choose an ORM tool -- after all every object-relational mapper can do this. Rather, we think that addressing the impedance mismatch should involve a straight-forward mapping process - more visual and with full mapping control - than writing code in order to generate the needed SQL. And this is where OpenAccess ORM comes in. It not only resolves the impedance mismatch, but provides a powerful Visual Designer which to allow you to do map entities visually, while providing you with the needed control. In addition, it provides all of the features that EF does not currently include like wide native DB support, support for query languages other than LINQ, and vibrant community with dedicated technical support.
As the subject of this blog suggests, in Q1 2011 we are making it extremely easy for you to upgrade EF-enabled projects to Telerik OpenAccess, and take advantage of OpenAccess's power. We have been working on this tool for some time, and we feel confident that it makes the project migration a breeze, so we decided to release it to the public as a beta.
The EF converter is a wizard with just 3 steps, two of which are completely informational. The most important step asks you about the conversion settings, such as the EF Model you want to convert, and the name and location of the file where the Telerik Model (dubbed RLINQ) will be saved. So, it is a rather easy wizard. Once you project is converted, you will be able to open the new model in the Telerik OpenAccess Visual Designer for additional editing, if your project so requires.
Here is a quick walk-through of the EF --> Telerik OpenAccess ORM converter, as well as some important
considerations that you need to be familiar with.
For the purpose of demonstrating the converter, we will use this simple Entity Framework model:
The model contains the following items from the Northwind database: Employees, Territories, EmployeeTerritories. The EmployeeTerritory join table is handled internally by the Entity Framework and an entity for that table is not generated.
To start the OpenAccess's EF Conversion wizard, you will need to have OpenAccess OM installed on the machine (download the Q1 2011 trial from here). Once you do this, select the target edmx file in Solution Explorer, right-click and select Convert from EF Model to Domain Model:
The start page of the wizard will appear -- it describes what will happen during the conversion process (these notes are included in the last section of this blog):
The second step is the place where you will need to specify the settings of the conversion, such as the EF Model you are about to convert, whether you would like to delete the corresponding connection string from the config file or not, the new namespace, and the Telerik Model file name and location. The dialog will also ask you where to back up your EF project, which we do to ensure that you can always go back to your original project in case you forget to back it up first:
When all settings are specified, a summary of what will happen appears:
Review them and click Finish to begin the veritable conversion.
The Conversion Process
Once you click the Finish button, the Entity Framework data model will be converted to a Telerik OpenAccess ORM Meta Model. Next, the converted domain model will be saved as a RLINQ file to the specified directory, and then will be 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. The wizard will exclude the original edmx file from the project and will delete the original connection string (only if you have checked that setting in the Settings page). As soon as these actions are executed, a new dialog will appear saying that conversion has completed successfully or has failed:
During the conversion each important action will be 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 "ConversionLog.xml".
The last step is to open the generated RLINQ file in Visual Studio and to press the Ctrl+S (File -> Save) command to generate the entities.
Now let's take a look at the project again:
As you can see the original edmx file is excluded (not deleted) from the project and the converter RLINQ file is included. References to Telerik.OpenAccess.dll and Telerik.OpenAccess.35.Extensions.dll are added to the project. If you take a look at the App(Web).config file, you will see that the original connection string is deleted and a new connection string in a different format is added. That connection string will be used by the OpenAccess Domain Model.
Before you start converting the EF Data Model to Telerik OpenAccess Domain Model, you should get familiar with the following important notes:
- The current version of the Telerik OpenAccess Entity Framework Converter supports only conversion of projects with data models generated by using the EF Data Wizard. You could convert Data Models 1.0 (.NET Framework 3.5) or Data Models 2.0 (.NET Framework 4.0).
- 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.
- Only conversion of edmx files with default code generation strategy is supported. Open your entity framework model in the visual designer, press F4 to open the Properties pane and ensure that the Code Generation Strategy property is set to Default.
- The name of the connection string in the configuration file must be the same as the entity container name. To check the entity container name, open the designer and press F4 to open the Properties windows. Check the Entity Container Name property.
- Conversion of complex types/properties is not supported currently.
- The Entity Framework converter supports conversion of flat and vertical inheritance hierarchies.
- Before starting the conversion, a backup of the project's original state will be created.
If you are looking for an alternative to Entity Framework, give the project convert a chance - we are sure you will like the OpenAccess experience. Download Telerik OpenAccess and see how easy it is to use. We will appreciate your comments.