Such an opportunity is possible with Telerik OpenAccess ORM, though it is not available out of the box. We offer a custom code generation text template (the file is attached at the end of the post) that allows data annotations. The annotation attributes it supports are:
The template should be included in your domain model project and requires several simple steps in order to generate the necessary code:
1) Add the OpenAccessMetadataTemplate.tt
template to the project and set its Custom Tool
if not set.
2) Add a reference to the System.ComponentModel.DataAnnotations.dll
3) Change line 11 as follows:
For Visual Studio 2010:
<#@ Assembly Name="C:\Program Files (x86)\Telerik\OpenAccess ORM\dsl2010\Telerik.OpenAccess.Common.UI.dll" #>
For Visual Studio 2012:
<#@ Assembly Name="C:\Program Files (x86)\Telerik\OpenAccess ORM\dsl2012\Telerik.OpenAccess.Common.UI.dll" #>
Make sure to replace the value of the assembly name with the full path to the Telerik.OpenAccess.Common.UI assembly on YOUR machine (the assumption is that OpenAccess might be installed in a directory other than Program Files
4) Change line 12 as follows:
<#@ Assembly Name="C:\Program Files (x86)\Telerik\OpenAccess ORM\bin\Telerik.OpenAccess.dll" #>
Again make sure to replace the value of the assembly name with the full path to the Telerik.OpenAccess assembly on YOUR machine.
5) Change line 43 as follows: replace "Path To Rlinq File Here" with the full path to your .rlinq file.
6) Change line 42 as follows: replace the items of the string array with the names of the domain entities you want to extend (e.g. the Person class).
7) Transform the OpenAccessMetadataTemplate.tt
template either by saving it or by invoking the Transform All Templates command in Visual Studio.
8) Open the generated OpenAccessMetadataTemplate.generated.cs file and add the attributes you need wherever you need them.
9) Save the OpenAccessMetadataTemplate.generated.cs file.
If you make any changes in the domain model that affect the data annotation (like addition of new column or change of the allowed string length) you should consider regenerating the data annotation code by invoking Transform All Templates.
Keep in mind that changes made in the generated code file could easily get lost if the file is regenerated!
If you need one-time code generation please delete/exclude from project the OpenAccessMetadataTemplate.tt in order to prevent any code loss in the generated file.
If you want to add additional data annotation attributes you can do it in the generated file, but make sure that the text template won't overwrite your changes.
If you experience any difficulties with the provided solution or have any other questions, do not hesitate to get back to us.
All the best,
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.