获取T4模板中的模型表名称

时间:2013-05-01 07:16:35

标签: asp.net-mvc-3 asp.net-mvc-4 t4 asp.net-mvc-scaffolding

我正在使用MVC4,T4脚手架和EF5。 我创建了一个模型,

namespace wbtest.Models
{
[Table(name: "Pay_Employees_Mst", Schema = "Test")]
public class Employee
 {
public int EMPLOYEE_ID { get; set; }
public string EMPLOYEE_CODE { get; set; }
}
}

我需要为db上下文获取表名“Pay_Employees_Mst”的注释。目前正在获取ModelName Employee。

请帮助。

1 个答案:

答案 0 :(得分:0)

我明白了,

String entityName1 = (context as System.Data.Entity.Infrastructure.IObjectContextAdapter).ObjectContext
  .CreateObjectSet<Employee>()
  .EntitySet.Name;
相关问题