views:

150

answers:

3

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.

+1  A: 

How about http://www.mygenerationsoftware.com?

nportelli
The weather is sure nice today
leppie
+1  A: 

If are looking specifically for a database/ORM generator you might be interested in looking at either llblgen or subsonic. Neither product is directly from Microsoft. Good luck with your search.

smaclell
+1  A: 

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.

Rory Becker