AFAIK T4 templates are called from within the Visual Studio IDE.
Building ORM requires more than text templates. I suggest you study AtomWeaver (at http://www.atomweaver.com ), which is a code generator that allows you to create models from individual building blocks (called “atoms”). These atoms are smart templates that act like text templates, but also as mini-programs, allowing for a much simpler line replacement.
You can create your own “Atoms” that transform the database structure into source code. Then, for each new database, you combine these Atoms to build your schema and run the generator to get the source code. Since what you built is actually a model of your database, you can make any changes in the future and restore your code.
AtomWeaver implements ABSE, a kind of model-oriented software development (has nothing to do with UML or MDA). Learn ABSE mechanics at http://www.abse.info
AtomWeaver is currently in open beta. There is not much documentation at the moment, so it may not be easy for you to get up to speed with it.
source share