Hi,
What code generation tools are built-in to vs.net 2008 or are officially available via Microsoft?
I know of:
- Entity Framework
- sqlmetal
What else is there?
Ideally i'm looking for something that will generate from an existing database schema.
Hi,
What code generation tools are built-in to vs.net 2008 or are officially available via Microsoft?
I know of:
What else is there?
Ideally i'm looking for something that will generate from an existing database schema.
I have recently discovered T4 which is built in to VS2008
Assuming VB.Net (although works with c# just as well)
Create a file called template.tt and put the following in it....
<#@ template language="VB" debug="True" hostspecific="True" #>
<#@ output extension=".vb" debug="True" hostspecific="True" #>
Imports System
<# For Each Table as String in GetMyTables() #>
Public Class <#=TableName#>
Public Sub New
End Sub
End Class
<#Next#>
<#+
Public Function GetMyTables() as String()
Return new String(){"Table1", "Table2"}
End Function
#>
Ensure (if using vb) that show all files is true....and save the file.
You should see that a new file 'Template.vb' has been created with 1 class for each of 'Table1' and 'Table2'
You should be able to see how to customise this for almost any type of code generation.