Hello Dragos,
In your scenario I suppose you can use our Add New Item Wizard to generate the RLINQ file in database first cases. Also Telerik OpenAccess ORM provides very helpful Web Services generation wizard based on the RLINQ file. Probably these functionalists are similar to the code you have and you can directly use them instead of you generators.
If for some reason you need to do it pragmatically I am attaching a simple project demonstrating how you can read the database schema and generate the RLINQ content from it. The sample uses the same infrastructure that helps the OpenAccess ORM Add New Item Wizard to generate the RLINQ file.
Example:
I hope that helps. Do not hesitate to contact us again if you have any other questions.
All the best,
Kaloyan Nikolov
the Telerik team