SubSonic2.0 的配置

1。 安装SubSonic2.03和SubSonic Tools2.03(SubSonic的官方网站http://www.subsonicproject.com/)。

2。 新建一个visual studio 2005的工程,数据库用Sql Server2000(建议用2005版本,实际上SubSonic同样支持mysql和oracle),先添加几个表。

3。 添加引用,浏览添加SubSonic.dll(SubSonic安装目录下),添加System.configuration引用。

4。 如果是Web应用程序按F5可以产生Web.config(或者手动添加,这不是什么难题),如果是WindowsForm或者Dll应用程序,手动添加App.config。在配置文件中添加:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <section name="SubSonicService"
          type="SubSonic.SubSonicSection, SubSonic"
         allowDefinition="MachineToApplication"
         restartOnExternalChanges="true"
         requirePermission="false"/>
      <section name="dataConfiguration"
         type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
         Microsoft.Practices.EnterpriseLibrary.Data" />
    </configSections>
    <appSettings/>
   <connectionStrings>
        <clear/>
        <add name="NorthwindConnection" connectionString="连接字符串"/>
     </connectionStrings>
     <SubSonicService defaultProvider="Northwind">
           <providers>
                 <clear/>
                 <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="NorthwindConnection"
      generatedNamespace="Northwind"
                 />
            </providers>
      </SubSonicService>
</configuration>

5。 VS菜单“工具-外部工具”,添加

标题:SubSonic DAL

命令:D:/SubSonic/SubSonic 2.0.3/SubCommander/sonic.exe

参数:generate /out App_Code/Generated

初始目录:$(ProjectDir)

钩选:使用输出窗口;提示输入参数;退出时关闭(推荐)

  为方便使用,在“工具-自定义”中“工具栏”新建“SubSonic”(默认钩选,显示),点“命令”-“工具”,数一下从“创建GUID”开始“SubSonic DAL”的位置即相应“外部命令某”,拖至“SubSonic”工具栏。

6。 在App_Code目录下建文件夹“Generate”,点击“SubSonic DAL”,确定即开始自动生成,完成后刷新项目即可看到生成在该文件夹下的代码。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值