Anonymous Cow
Anonymous Cow

Reputation:

Built in code generation in vs.net 2008? or free via MS?

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.

Upvotes: 0

Views: 200

Answers (3)

Rory Becker
Rory Becker

Reputation: 15731

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.

Upvotes: 1

smaclell
smaclell

Reputation: 4658

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.

Upvotes: 1

nportelli
nportelli

Reputation: 3916

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

Upvotes: 1

Related Questions