T4 Code Generation question

2 posts, 0 answers
  1. Harald Bacik
    Harald Bacik avatar
    13 posts
    Member since:
    Aug 2009

    Posted 20 Jun 2013 Link to this post


    I am new about changing T4 templates. So, I hope, anyone out there could help me please with a step-by-step Information.
    I want to Change the Code Template, so the following lines should be set as Friend and not Public

    Public Sub New()
            MyBase.New(connectionStringName, backend, metadataSource)
        End Sub
        Public Sub New(ByVal connection As String)
            MyBase.New(connection, backend, metadataSource)
        End Sub
        Public Sub New(ByVal backendConfiguration As BackendConfiguration)
            MyBase.New(connectionStringName, backendConfiguration, metadataSource)
        End Sub
        Public Sub New(ByVal connection As String, ByVal metadataSource As MetadataSource)
            MyBase.New(connection, backend, metadataSource)
        End Sub
        Public Sub New(ByVal connection As String, ByVal backendConfiguration As BackendConfiguration, ByVal metadataSource As MetadataSource)
            MyBase.New(connection, backendConfiguration, metadataSource)
        End Sub

    So, as I wrote above, I don't want to have this Sub New as public, I want it as Friend

    THX for advise
    Have a nice day
  2. Dimitar Tachev
    Dimitar Tachev avatar
    67 posts

    Posted 21 Jun 2013 Link to this post

    Hi Harald,

    In order to achieve this you could follow the steps below:

    1) Go to the Code Generation Templates folder of the Telerik OpenAccess ORM which could be found here:


    C:\Program Files\Telerik\OpenAccess ORM\dsl2012\

    2) Copy the DefaultTemplateVB.tt file and the Includes_ver.2 folder.

    3) Paste them in the project containing your RLINQ file which you want to modify (e.g. in folder named OpenAccessTemplates).

    4) Remove the custom tool settings from the properties of the DefaultTemplateVB.tt file.

    5) Go to the ContextGenerator.ttinclude and modify the access modifiers of the constructors in the GenerateConstructorsAndMappingSource method.

    6) Set the custom template from the Code Generation tab of the Model Settings of your Domain Model.

    7) Save your RLINQ file in order to regenerate its classes.

    For your convenience I also created a sample application demonstrating this approach - please find it attached.

    Please bear in mind that the sample and the steps are based on our latest release Q2 2013 and you will need to update your OpenAccess ORM if you use an older version.

    With this release you could also take advantage of our new code generation features. They are out-of-the-box generation of DataAnnotation attributes, implementing the INotifyPropertyChanged, INotifyPropertyChangind and the IDataErrorInfo interfaces.

    I hope this helps. Do not hesitate to  contact us back if you need any further assistance.

    Dimitar Tachev
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
Back to Top