I am new to this platform. So, I'm not familier with all the terminologies.
I'm getting the error message :
A specified Include path is not valid. The EntityType 'ERP.Models.OpeningBalance' does not declare a navigation property with the name 'AccountHeadId'.
Here I got a Model class 'OpeningBalance' in the project 'ERP'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
namespace ERP.Models.Account
{
public class OpeningBalance
{
[Key]
public int OpenningBalanceId { get; set; }
[Required(ErrorMessage = "The {0} cannot be left blank.")]
[Display(Name = "Openning Balance Date")]
[DataType(DataType.Date)]
[DisplayFormat(NullDisplayText = "", DataFormatString = "{0:dd-MM-yyyy}")]
public DateTime OpenningBalanceDate { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} cannot be left blank.")]
[Display(Name = "AccountHeadId")]
public int AccountHeadId { get; set; }
public virtual ChartOfAccount ChartOfAccount { get; set; }
}
}
Isn't the public int AccountHeadId { get; set; } is
a navigation property with the name 'AccountHeadId'
?
The Source Error shows the lines from Controller :
var openingBalances = db.OpeningBalances.Include(o => o.AccountHeadId);
return View(openingBalances.ToList());
I searched a lot in web including all related ques in stackoverflow, then tried the following form:
var openingBalances = from o in db.OpeningBalances.Include(o=>o.AccountHeadId) select o;
return View(openingBalances.ToList());
That didn't work too. Anybody have any idea?