I’d like to use some T4 templates to generate html files derived from a sql server (in this case) database schema. For each table in the database, I would like to create 2 files:
-
tableName_List.aspx – would contain the appropriate html to display in an asp.net GridView, with a grid column defined for each db table column
-
tableName_Edit.aspx – would contain the appropriate html to display in an asp.net FormView, with a textbox (for simplicity’s sake, for now) for each db table column
So, if I have 5 tables in the database, I would get 10 files output. I’ve been googling this and found related articles, but most of them don’t seem to address this scenario. I’ve also seen references to using subsonic for this, but I’d rather not introduce yet another technology into the mix.
The code for the T4 template below will give you a relatively good start.
You will need to add references to the appropriate versions of the Microsoft.SqlSserver Smo DLLs to the project.
The following items need to be replaced in this code with the appropriate values for your environment:
SERVERNAMEGOESHERE
DATABASENAMEGOESHERE
PROJECTNAMESPACEGOESHERE