Top 10 Must Have Features in O/R Mapping Tools

Feature 8: Object Caching

If your application is transaction intensive and supports high traffic, you really cannot live without effective caching built into your application. Microsoft provides an ASP.NET Cache object but it is not sufficient for clustered environments where your application is running on multiple servers and needs a cache that is also clustered. However, there are commercial caching solutions available in .NET that cater to clustered environments.

Whichever caching product you use, you will have to make sure that your persistent objects are making caching calls from appropriate locations. And, your O/R mapping tool should provide the ability to generate code that makes caching calls to one or more leading products.

Ideally, your O/R mapping tool should let you specify which objects you want to cache and which ones you do not want to cache. The most popular situation is where transactional objects (single row objects) are cached. However, you can also cache entire collections and even related objects

Feature 9: Customization of Generated Code

You will always have situations where you need to customize generated code. However, if you change the generated code, it will most likely be overwritten the next time you generate code again. And, since software development is an iterative process, you will have to generate code many times.

Additionally, whatever custom code you write must be called when the generated code is run. And, it must be able to control the subsequent execution of the generated code. For example, if your custom code is called before doing an “Insert” and you find something wrong, you should be able to prevent the “Insert” from actually happening.

To prevent your code from being overwritten in future code regenerations, the O/R mapping tool must allow you to mark your code as “Safe Code.” And, to ensure that your custom code gets called seamlessly, the O/R mapping tool needs to either support the concept of “Hooks” which are calls made from strategic places in the generated code and the result code returned by these “Hooks” determines what happens next. Or, the O/R mapping tool needs to let you derive the generated code and then use polymorphism to run your code instead of the generated code. You can then determine whether to call the “base class code” or not.

Feature 10: Template Customization

A good O/R mapping tool is very likely using code templates to determine how to generate the code. The O/R mapping tool combines the templates it has with a combination of your object mapping input and the database schema information to determine exactly how to generate the code.

Since the O/R mapping tool is generating code from templates, it would be great if it let you modify these templates (or add new templates) so you could affect how the generated code should look.

A very simple example would be one in which you would like to put your own copyright header in each source code file. If you could insert this header in the code template file, it would automatically be used next time you generate code. You should also be able to write your own code templates (although this is only for advanced users) and let the O/R mapping tool use your templates but do everything else the same way as it always does.


You should seriously consider using an O/R mapping tool as it would save you a lot of development and testing time. And, when it comes to evaluating which tool is best for you, you should know what to look for. I hope this article helps you gain a better understanding of O/R mapping.

Iqbal M. Khan works for Alachisoft, a leading software company providing O/R mapping and clustered object caching solutions for .NET. You can reach him at or visit Alachisoft at

Pages: 1 2 3 4


No comments yet... Be the first to leave a reply!