Subsonic is an ORM tool that works up your database access and can speed your development cycle. It can be downloaded from Subsonic. To use subsonic in your visual studio express project you can follow the steps below:
1) in your project add a reference to the subsonic.core.dll
2) create a folder Dal – the generated classes will be put in this directory
3) create a folder Model and populate it with the subsonic T4 templates.
4) create a batch file ie. model.bat and add the following:
5) create a vs external tool with:
Title: s/ing like Subsonic 3 ?
command: %SystemRoot%\system32\cmd.exe
argument: /C "model\model.bat"
Initital Directory: $(ProjectDir)
6) modify the Settings.ttinclude with the connection string of your db and your namespace for the generated code according to the Subsonic documentation.
7) if T4 throws exceptions modify the Settings.ttinclude as explained in this Stackoverflow question.
Note1: if you want to build each .tt file separately follow the steps below:
a) replace the contents of the model.bat with the following:
call "C:\Program Files\Common Files\microsoft shared\TextTemplating\1.2\TextTransform.exe" -out %1 %2
b) set the argument of the external tool with:
/C "model\model.bat Dal\$(ItemFileName).cs model\$(ItemFileName)$(ItemExt)"
Note 2: keep the quotes, it’s important!
No comments:
Post a Comment