3

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.

user2156088
  • 2,350
  • 5
  • 20
  • 24

1 Answers1

0

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

Community
  • 1
  • 1
RobV8R
  • 1,036
  • 8
  • 16