C# T4工具箱Linq2Sql

C# T4工具箱Linq2Sql,c#,linq-to-sql,t4,t4-toolbox,C#,Linq To Sql,T4,T4 Toolbox,我正在尝试使用t4toolbox为项目生成linq2sql类。已经有很多代码是针对默认dbml生成的代码编写的 在LinqToSqlEntityClassTemplate.tt文件中 /// <para> /// While MSLinqToSQLGenerator generates field names as property name with an /// underscore prefix, this method simply converts the property

我正在尝试使用t4toolbox为项目生成linq2sql类。已经有很多代码是针对默认dbml生成的代码编写的


在LinqToSqlEntityClassTemplate.tt文件中

/// <para>
/// While MSLinqToSQLGenerator generates field names as property name with an
/// underscore prefix, this method simply converts the property name to camelCase.
/// This is done for consistency with the StyleCop rule SA1306: Variable names
/// must start with a lower-case letter.
/// </para>
//
///而MSLinqToSQLGenerator则使用
///下划线前缀,此方法仅将属性名称转换为大小写。
///这样做是为了与StyleCop规则SA1306:变量名保持一致
///必须以小写字母开头。
/// 
有没有办法让它以默认方式(VisualStudio方式)生成文件,而不是使用大小写且没有下划线


t4toolbox生成的代码由于字段名的差异而导致400多个错误。

您可以复制要在项目中修改的T4 Linq2Sql模板。您只需创建与T4Toolbox中相同的层次结构:在项目的根目录下,添加文件夹
T4Toolbox/LinqToSql
,然后将模板
LinqtoSqEntityClassTemplate.tt
从T4Toolbox安装复制到项目中。您只需编辑
FieldName
方法即可更改字段的命名


在LinqToSqlEntityClassTemplate.tt中,我看到两个字段名定义。它们都返回FieldName(prop)。转换属性名的FieldName()方法在哪里?它位于base
T4Toolbox.dll
中,并提供相应的大小写。您必须同时更改
字段名(列)
字段名(关联)
,以满足您的需要。谢谢,我想这就是我需要知道的。