3
votes

Using MVC4 and T4 Template(Scaffolding) I am creating a model in mvc4 and specify the table name in DBContext. 1)I need to get the table from Dbcontext against model name. 2)Need to get value from annotation Table.

[Table(name: "Pay_Emp_Qualifications", Schema = "Sample")]
public class EmpQualification
{
    [Key]
    public int EMP_QUALI_ID { get; set; }
    public String Qualification { get; set; }
}

Currently we getting load the dll against the model and using reflection we get.We are trying to avoid this dll

var  objFile= Assembly.LoadFile(@"bin\wbtest.dll");

var objMaster = AppDomain.CurrentDomain.Load(new AssemblyName(Convert.ToString(objFile))).CreateInstance(namespaceInstance);

 var attributeData = objMaster.GetType().GetCustomAttributesData().Select(p =>           p.ConstructorArguments).ToArray();
           var tableNameVariable= attributeData[0][0].Value.ToString();

How to get table name against model name in t4 template without using dll,we using ModelProperty class. Please Suggest.

1
if the question is unclear please ask.user2156088

1 Answers

0
votes

While this doesn't exactly answer your question, it gives you an alternative way of loading the assembly so that it doesn't lock it. T4 and MSBuild integration issues