Fork me on GitHub

ST4bby ("Stabby")
by jbubriski and codeimpossible

ST4bby (A Standalone T4 POCO Generator)

ST4bby is a T4 template that will generate POCO's (Plain Old CLR Objects) from your database tables and columns. It doesn't rely on any particular ORM but can be used in conjunction with them, including but not limited to:

  1. Entity Framework
  2. Dapper
  3. Massive
  4. Anything else that uses POCO's relating directly to your database schema.

Features

How do I use it?

Here is all you need to do:

After that, you can continue to run the T4 template as you update the database, or you can delete the T4 templates and keep the POCO's.

Limitations:

Currently there are no major limitations, but there may be some issues surrounding decimal support. Decimals are supported, but the differences in the lengths of the SQL Server equivalent datatypes may cause issues. If you're storing "big" numbers, make sure they don't get truncated when going into SQL Server.

Only a few Data Annotation attributes are currently supported (Key, Required, and StringLength). Ideally we will support all related validation attributes (if there are in fact more).

Dependencies

None!

Contributing

Please don't be afraid to contribute, but because of the sensitive nature of T4 here are a some guidelines:

  1. It's tempting, but I wouldn't recommend use of the Visual Studio Extensions for syntax highlighting and intellisense. Unfortunately it seems like most of the extensions have some major issues with formatting and report misleading errors (or maybe that's just a T4 thing). Our recommendation is to use a 3rd party editor like Notepad++ to enable syntax highlighting and use a test app for intellisense when you need it.
  2. To help keep the diffs clean make sure you only change what's needed and use spaces instead of tabs. Again, extensions tend to fubar the whitespace, so be careful and check your diffs before submitting pull requests.

Authors / Contact

John Bubriski ([email protected])
Jared Barboza ([email protected])

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/jbubriski/ST4bby

HA HAAAAAAAAA!!!!

    ..............................................................................................................................
    ............................  ....:.:... .....................................................................................
    ....................... ::::ccccccccccccccc. ................. .. .:ccccccc:..................................................
    ......................:::.cccccc:.    .:cccccc ............ ::..ccccccccccccccc ..............................................
    ................... :::::cccc             .cccc:......... :::.ccccc:       :ccccc ............................................
    ...................:::.cccc.     :oc        :cccc ...... ::::cccc             cccc ...........................................
    ................. :::::ccc     @@@@@@@8c     :ccccccccccccccccc.      .O@@@c   .ccc ..........................................
    .................::::.ccc:   .@@@@@@@@@@@@o   ................     c@@@@@@@@@   :cc:..........................................
    .................::::.ccc.   8@@@@@@   @@@@                      c@@@@@@@   @O  .ccc .........................................
    .................::::.ccc:   C@@@@@@88@@@@8                      :@@@@@@@@@@@C  :cc: .........................................
    ................. :::::ccc    O@@@@@@@@@@8                        o@@@@@@@@@O   ccc ..........................................
    ...................::::cccc.    C@@@@@@O.   cccccccccccccccccccc.   c8@@@@o   .ccc............................................
    ................... ::::ccccc.            :cccc:cccccccccccccc:ccc:         :cccc ............................................
    .................... .::::ccccccc:....:cccccc:.:ccccccccccccc::.:cccccccccccccc ..............................................
    ....................... .:::cccccccccccccc:.::::cccccccccccccc   .  .:cccc:. .................................................
    ..................................... .:::::::.cccccccccccccc.................................................................
    ...................................... ::::::::.cccccccccccccc ...............................................................
    ...................................... :::::::: cccccccccccccc .......................................................oO888c..
    .............................. .....   :::::::: cccccccccccccc ...................................................:C88O8888c..
    .......................... .::::::::::.::::::::.cccccccccccccc...........................................:: ...:C888888888C...
    .........................:::::::::::.. ::::::::::cccccccccccccc .........................................: .:oO88CO888888O....
    ...................... :::::::::.:cccc:::::::::::.cccccccccccccc ........................................:o888OO88888888O:....
    ......................::::::::.ccccccc:::::::::::::cccccccccccccc......................................oO88CO8888888888O:.....
    ................... ::::::::.ccccc......:::::::::::cooooc....:cc ...................................:O88OO888888888888O.......
    ..... ..:::::::::::::::::::.ccccc.... . ::::::OC88C888888.   .....................................o88OC88888888888888c........
    .... :::.:::::::::::::::::.cccccc.... . ::::coOCOOCOOOOOC... ..................................cO8OCO88888888888888C..........
    .... ::::::.::::::::::::::ccccccc:....  ::::::Oo88C88COOc...................................:O88CO888888888888888o............
    .... ::::::::.........:::ccccccccccccccc::::::::::ccccccccc:.............................:C88CO888888888888888Oc..............
    .... .ccccc:.::ccccccccccccccccccccccccc.::::::::.ccccccccc.........  . :ccc::c...     cO8OCO888888O8888888Oc.................
    ... ccccccccc.ccccccccccccccccccccccccccc.::::::.ccccccccc ... :ccccccccc:.cc.:.:.:::C8888C8888888888888Oc: ..................
    .. ccc.........:ccccc:::.:.:::cccccccccccccc....:.:....   ...ccccccccccccccc..::::.::o8888888O888O8OCc.. . ...................
    .  cc:....... ...... ..:ccccccccccccccccccccc:ccccc:cc.. . cccccccccccccccccc ::::: .:o888888OCo:....... : ...................
    .. ccc ..... ................. .  ......:::::.:::: . .... cccccccccccccccccccc.:::::..:::: ............. : ...................
    ... cccc:... ............... ......... .......... .......ccccccccccccccccccccc.:::::::::::: ............ . ...................
    ...::.:cccc:......................... .......... ........cccccccccccccc.:c:..c::::.:.. . .  .........    :    ................
    .. ::::::::::cccccc. ................ .......... .........cccccccccccc.cccccc.... . . .  ........... ...::::: ................
    .. :::::::::cccccc:cccccccc:.................... .........cccccccccccc::ccc.ccccc................  ..............  ...........
    .. ::::::::.cccccc.ccccccccccccccccccccc::....      ...... .ccccc.ccccc:.c.ccccccc:cc........ ........................  ......
    ..:::::::::.cccccc:cccccccccccccccccccccc.ccc........... .::..ccc:cccccc...:cccc::c...... ................................ ...
    ..::::::::::ccccccccccccccccccccccccc::.:ccc:...........   ....   :ccc::cccc:c:  ...... ......................................
    . :::::::::ccccccc::::......:::ccccccccccccc ........... .   . ..   .c:cccc.cc:...... ........................................