Sunday, March 30, 2008

SubSonic step by step

  

SubSonic step by step

I. SubSonic is a toolset that helps to

  1. Generate DAL layer
  2. Maintains and Generates SQL Script for DB Versioning
  3. Dynamic Query tool helps to use SQL Server etc without knowing SQL
  4. OR Mapper that extends to views and stored procedures

II. Installation

  1. Download SubSonic @ http://www.codeplex.com/subsonic/Release/ProjectReleases.aspx?ReleaseId=5636
  2. Install SubSonic by walking through steps, by default it stores at “Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic”

III. Configuring inside Visual Studio 2005/ 2008 to use SubSonic

  1. Create new Website project
  2. Create another new class library project say ‘NorthWindDAL’ and add to solution as shown below (this project is going to act as DAL layer for web project)

  1. Add application configuration file to ‘NorthWindDAL’ class library (app.config)
  2. Create folder in NorthWindDAL project to keep all Subsonic generated classes
  3. Add below configuration sections to app.config file of NorthWindDAL project
    1. Add configsection

<configSections>
                  <section name=SubSonicService
                         type=SubSonic.SubSonicSection,SubSonic
                         requirePermission=false/>

   </configSections> 

  1. add Connection strings section

<connectionStrings>
<add name=NorthWind               connectionString=Server=yourserverName;Database=dbName;UID=youruserName;PWD=yourPassword;/>

   </connectionStrings> 

  1. add Subsonic service provider

<SubSonicService defaultProvider=NorthWind>
            <providers>
                  <clear/>
                  <add name=NorthWind
                         type=SubSonic.SqlDataProvider, SubSonic
                         connectionStringName=NorthWind
                         generatedNamespace=NorthWind  />
            </providers>
   </SubSonicService>

  1. Goto Bin folder of NorthWindDAL project and give reference to ‘SubSonic.dll’ available at “Program Files\SubSonic\SubSonic 2.1 Beta 2\SubSonic”
  2. and add reference to System.Web and System.Configuration

IV. Adding SubSonic Commander as external tool in Visual studio

Now you are ready for generate code.

When you click on External tool ‘SubSonicDAL’ , it generates code in specified folder that is ‘NorthWind’

That’s it…..  so simple

Posted by in 11:45:46
Comments

Leave a Reply