While Fetching data from tables if you face below
error…
Image 1.
To avoid this error replace your code with below code:
public ActionResult Index()
{
var students = (from p in objContext.Students
join f in objContext.Courses
on p.CourseId equals f.CourseId
select new
{
Id = p.Id,
Name = p.Name,
DateOfBirth =
p.DateOfBirth,
EmailId =
p.EmailId,
Address =
p.Address,
City = p.City,
CourseName =
f.CourseName
}).ToList()
.Select(x => new Student()
{
Id = x.Id,
Name = x.Name,
DateOfBirth =
x.DateOfBirth,
EmailId = x.EmailId,
Address = x.Address,
City = x.City,
CourseName = x.CourseName
});
return View(students.ToList());
}

Image 2.