我已经在VS2010中下载了MVCScaffolding nuget包。我试图从我的模型中检索[DisplayName数据注释,以便在index.cs.t4模板中使用它。
此页面OneToMany Relationships向我展示了如何修改索引模板以提供链接,该链接将我带到我的子对象的控制器索引。在这种情况下,从电子邮件到电子邮件收件人。问题是我已经调用了我的控制器emailcontroller和emailrecipientscontroller,而不是他们的描述性较少的表名,我宁愿隐藏它们。我同样装饰了t4模板使用的metadataobject(tbl_My_unwieldytablename_emailMetadata)和这个displayname(emailrecipients)数据注释,我希望我可以修改模板以替换关系的名称以使用displayname这是我的控制器名称即< / p>
[MetadataType(typeof(tbl_My_unwieldytablename_emailMetadata))]
public partial class tbl_My_unwieldytablename_email
{
internal sealed class tbl_My_unwieldytablename_emailMetadata
{
[ScaffoldColumn(false)]
[Required(ErrorMessage="id is required")]
public Int32 id { get; set; }
[DataType(DataType.Date)]
public DateTime send_date { get; set; }
[StringLength(255)]
public String title { get; set; }
[DataType(DataType.MultilineText)]
public String message { get; set; }
[StringLength(50)]
public String author { get; set; }
[StringLength(80)]
[DataType(DataType.EmailAddress)]
public String author_email { get; set; }
[DataType(DataType.MultilineText)]
public String attachment { get; set; }
[DataType(DataType.Date)]
public DateTime created_date { get; set; }
public Int32 batches { get; set; }
[DataType(DataType.Date)]
public DateTime complete_date { get; set; }
[DisplayName("emailrecipients")]
public EntityCollection<tbl_My_unwieldytablename_email_recipients> tbl_My_unwieldytablename_email_recipients { get; set; }
}
干杯 添
答案 0 :(得分:-1)
[Table("tbl_My_unwieldytablename_email")]
Public Class Email
[Table("tbl_My_unwieldytablename_email_recipients")]
Public Class EmailRecipients
应该将您的类映射到数据库表