I am getting below error. A specified Include path is not valid. The EntityType 'testDB_KYC3Model.ts_upld_doc' does not declare a navigation property with the name 'Fields'.
This is my ts_upld_doc class.
public partial class ts_upld_doc
{
string _template;
public ts_upld_doc()
{
this.tr_upld_content = new HashSet<tr_upld_content>();
}
public List<tr_doc_content> Fields { get; set; }
public int upld_docid { get; set; }
public int usr_createdby { get; set; }
public Nullable<int> upld_clientid { get; set; }
public virtual ICollection<tr_upld_content> tr_upld_content { get; set; }
}
this is my tr_doc_content class
public partial class tr_doc_content
{
public int doc_contentid { get; set; }
public int doc_typeid { get; set; }
public string doc_contenttypelabel { get; set; }
public string doc_ctrltype { get; set; }
public string doc_fieldtype { get; set; }
public Nullable<bool> doc_isrequired { get; set; }
public Nullable<bool> doc_isactive { get; set; }
public virtual tm_doc_type tm_doc_type { get; set; }
}
I have on more class with some functions written in it.
public DbDrivenView(string viewName)
{
if (string.IsNullOrEmpty(viewName))
{
throw new ArgumentNullException("viewName", new ArgumentException("View Name cannot be null"));
}
_viewName = viewName;
}
public void Render(ViewContext viewContext, TextWriter writer)
{
ts_upld_doc dataForm = dbContext.ts_upld_doc.Include("Fields").First(f => f.upld_employeename == _viewName);
var sb = new StringBuilder();
var sw = new StringWriter(sb);
using (HtmlTextWriter htmlWriter = new HtmlTextWriter(sw))
{
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Div);
foreach (var item in dataForm.Fields)
{
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Div);
htmlWriter.WriteEncodedText(item.doc_contenttypelabel);
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Id, item.doc_ctrltype);
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Name, item.doc_ctrltype);
htmlWriter.RenderEndTag();
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Div);
}htmlWriter.RenderEndTag();
}
writer.Write(dataForm.Template.Replace("@DataFields", sb.ToString()));
}
when i debug this code I am getting below error Exception Details: System.InvalidOperationException: A specified Include path is not valid. The EntityType 'testDB_KYC3Model.ts_upld_doc' does not declare a navigation property with the name 'Fields' near this line of code.
ts_upld_doc dataForm = dbContext.ts_upld_doc.Include("Fields").First(f => f.upld_employeename == _viewName);
Please help me in sorting out this.