It sounds like you are trying to put the results into one model but your linq query isn't returning one model. That issue will be eaten up by the
var
keyword. If you were to change that to be type
Models.DoctorMaster
instead, I think you would see the error earlier. To fix this, change your linq query to look like this:
public ActionResult Edit(int id)
{
Models.DoctorMaster DocMstrEdit = (from v in context.DoctorMasters
where v.nCode == id
select v).FirstOrDefault();
return View(DocMstrEdit);
}
That will ensure that you only return one model into your variable. When you are expecting one model, it is always best to do this, even if you are querying a value that should only return one entry.