My name is Jan Blessenohl and I am working on the new Telerik object relational mapper named OpenAccess ORM. In the next posts I would like to guide you through the first steps with OpenAccess. This post is about reverse engineering. The following posts will use this feature to build running applications.
OpenAccess comes with 2 possible ways to generate the persistent model:
This step by step guide shows how you can reverse engineer an existing schema to a class library with Visual Studio 2005 or 2008.
Step 1:. Open Visual Studio and create a new class library project (C# or VB)
Step 2: Select the class library project in the project explorer and start the OpenAccess Enable Project Wizard from the OpenAccess menu (Visual Studio menu bar)
Dialog 1: Press Next
Dialog 2: Only the Persistent Classes checkbox should be checked, press Next
Dialog 3: You have to specify which database you want to use. To use Northwind from my local Microsoft Sql Server Express instance I have to specify
Server Name: (LOCAL)\SQLEXPRESS
Database Name: Northwind
Dialog 4: Press Finish
Now the project knows how to access the database schema and we can start the reverse engineering step.
Step 3: Start the Reverse Engineering Wizard from the OpenAccess Menu
The wizard reads the complete database schema now and generates a default mapping to classes and fields. In the next steps you can configure the class model to fulfill your needs.
Step 4: Set the class names.
In the first tab you will find all tables in a grid. Here you are able to specify the way a table is mapped. OpenAccess tries to find out if a table should be mapped to a class, collection or map. If the table looks like a join table, we do not map it to a concrete class but to a collection which becomes into a field at the class where the first foreign key reference points to. You can change all these settings. A necessary step is to look if you are happy with the OpenAccess generated class names.
Step 5: Open the Advanced View tab.
Decide where you want to have collections in your model. Besides the join tables we are not generating collections by default; only the reference fields are generated. To generate a collection field as the opposite of a reference you have to select the corresponding reference in the tree view and check the 'Create one-to-many list' checkbox. You can specify the names of both the collection and reference.
If everything is right, click the 'Generate & Save Config' Button to start the generation process. The wizard generates source files for all classes, a mapping file (app.config) and the wizards settings file (reversemapping.config) into your class library project.
You are done now and can compile your project. My result can be downloaded here.
The next step is to generate a website or winforms application. I will follow up with posts about it.
Enjoy your firsts steps with OpenAccess as I am doing.
Copyright © 2016, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.