1. 在 Web.config文件中添加的三个段代码
a.
<!--SubSonic section handler--><configSections><section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic"/></configSections>
b.
<!-- Connection String(s) -->
<connectionStrings>
<!-- SqlServer数据库 -->
<add name="DefaultConnection" connectionString="Data Source=192.168.101.151;Initial Catalog=jz_power;User Id=jz_power_admin;Password=123;"providerName="System.Data.SqlClient"/>
</connectionStrings>
c.
<!-- Point SubSonic at the appropriate data source(s) -->
<SubSonicService defaultProvider="DefaultProvider">
<!— 与下面的一个name必须一样 -->
<!— 如果有两个数据源,系统会自动以每个数据源的name做文件名创建文件夹,
<SubSonicService defaultProvider="DefaultProvider">
<!— 与下面的一个name必须一样 -->
<!— 如果有两个数据源,系统会自动以每个数据源的name做文件名创建文件夹,
并把数据放在相应的文件夹当中 -->
<providers>
<add name="DefaultProvider" type="SubSonic.SqlDataProvider, SubSonic"connectionStringName=" ClubSiteDB " generatedNamespace="Club"/>
<add name="vehicle" type="SubSonic.SqlDataProvider, SubSonic"connectionStringName="ConnectionVehicleInformation"generatedNamespace="WHMESMS.dal.vehicle"/>
</providers>
</SubSonicService>
2. VS中添加SubSonic工具
- 在VS工具中添加名为SubSonic工具
Command: D:/…/sonic.exe
Arguments: generate /out dal
Initial directory: $(ProjectDir)
- 在Web工程中添加引用 --- subSonic.dll
- 运行SubSonic工具 --- 把生成的文件添加到工程中