我正在学习DotNet Core。
这是我的控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Practinig_Student.Models;
using Microsoft.EntityFrameworkCore;
using System.Data.Entity;
namespace Practinig_Student.Controllers
{
public class EmployeeController : Controller
{
private readonly EmployeeContext _dbcontext;
public EmployeeController(EmployeeContext dbContext)
{
_dbcontext = dbContext;
}
public IActionResult Employee_Details(int id)
{
// EmployeeContext employeeContext = new EmployeeContext();
//Employee employee = dbContext.Employees.Single(emp => emp.Id == id);
var emplst = dbContext.Employees.Single(emp => emp.Id == id);
return View(emplst);
}
}
}
我在排队时出错了
var emplst = dbContext.Employees.Single(emp => emp.Id == id);
我无法进入的地方
dbContext
我得到的错误是
当前上下文中不存在名称dbContext
我尝试了很多解决方案,但都没有出错。我也不明白为什么会出现错误。帮助我。