[英]“Invalid Column Name” in C#
即使所有列都存在于 Sql Server 的表中,我在 Visual Studio 中收到错误“无效的列名”。 表列名称是 AttandanceId 但它显示“无效的列名称”错误,即。 AttandanceId1 在 Attandance 下的 Sql Server 表中不存在
public IActionResult EmployeeReport(int id)
{
var viewModel = new AttandanceViewModel();
var EmployeeList = _dbContext.Employees.ToList();
viewModel.DropFirstName = new SelectList(EmployeeList, "EmployeeId", "FirstName");
viewModel.AttList = _dbContext.Attandance.Where(i => i.EmpId == id).ToList();
ViewBag.Id = id;
var Count = viewModel.AttList.Count();
ViewBag.Counts = Count;
return View(viewModel);
}
我认为您对 sql 表进行了一些更改,然后尝试更新未成功更新的数据模型,例如,正如您提到的 AttandanceId 和 AttandanceId1 显示冲突。
简单地做
1:删除您的表或完整模型并清理您的解决方案。
2:再次添加表/模型并构建您的解决方案,每个想法都会
美好的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.