SubSonic配置与使用的学习与报错

最近公司的项目需要用SubSonic来做。所以作为菜鸟的我又要开始SubSonic的学习之旅了。

1、首先是webconfig的配置:

  a、在<configuration>\<configSections>中添加信息

<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic"/>

  b、在<configuration>中添加connectionStrings

View Code
1 <connectionStrings>
2 <clear/>
3 <add name="Default" connectionString="Password=sa;Persist Security Info=True;User ID=sa;password=111111;Initial Catalog=AppBox;Data Source=."/>//我也不知道为什么name是default。但是其他的信息就都是数据库的具体信息啦~~
4 </connectionStrings>

  c、添加Provider信息

View Code
1 <SubSonicService defaultProvider="Default">
2 <providers>
3 <clear/>
4 <add name="Default" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Default" generatedNamespace="AppBox"/>
5 </providers>
6 </SubSonicService>

2、通过SubSonic.exe生成所有映射类

  把下面一行命令保存为批处理文件(比如generate.bat),双击运行即可生成所有的数据库映射类代码(以后表有改动,只需重新执行一次这个命令即可)。

.\library\subsonic\sonic\sonic.exe generate /config .\ /out .\Business\Subsonic
这个命令中:
  • /config .\
    执行使用当前目录下的 Web.config 中的SubSonicService建立数据库连接。所以此generate.bat应该和Web.config在同一目录。
  • /out .\Business\Subsonic
    指定输出目录为当前目录下Business目录下的SubSonic子目录。

3、所生成的映射类文件放置于App_Code文件夹下,否则会产生表所在的命名空间无法找到的问题

 

更多配置信息。亲~~请参阅三石的http://www.cnblogs.com/sanshi/archive/2009/08/25/1553917.html

posted @ 2012-07-30 14:02  Ro_s__  阅读(289)  评论(0编辑  收藏  举报