轉自:https://www.cnblogs.com/wrhming/p/6084839.html
1.修改動軟生成器Model模板(簡單三層模板)
1 <#@ template language="c#" HostSpecific="True" #> 2 <#@ output extension= ".cs" #> 3 <# 4 TableHost host = (TableHost)(Host); 5 host.Fieldlist.Sort(CodeCommon.CompareByintOrder); 6 #> 7 using System; 8 using System.Text; 9 using System.Collections.Generic; 10 using System.Data; 11 namespace <#= host.NameSpace #>.Model<# if( host.Folder.Length > 0) {#>.<#= host.Folder #><# } #> 12 { 13 <# if( host.TableDescription.Length > 0) {#> 14 //<#= host.TableDescription #> 15 <# } #> 16 public class <#= host.GetModelClass(host.TableName) #> 17 { 18 19 <# foreach (ColumnInfo c in host.Fieldlist) 20 { #>/// <summary> 21 /// <#= string.IsNullOrEmpty(c.Description) ? c.ColumnName : c.Description #> 22 /// </summary> 23 public <#= GetTypeName(c) #> <#= c.ColumnName #>{ get; set; } 24 <# } #> 25 } 26 27 28 } 29 30 31 <#+ 32 private string GetTypeName(ColumnInfo c) 33 { 34 if(c.Nullable && (CodeCommon.DbTypeToCS(c.TypeName).ToString().ToLower())!="string") //如果字段可以爲空,並且不是字符串類型 轉換爲可空類型 35 { 36 return CodeCommon.DbTypeToCS(c.TypeName)+"?"; 37 } 38 39 else 40 { 41 return CodeCommon.DbTypeToCS(c.TypeName); 42 } 43 44 } 45 46 #>
2.替換安裝目錄下 Maticsoft.DbObjects.dll
http://pan.baidu.com/s/1gfa9zvt