System.Data.Entity.Core.ProviderIncompatible Exception in MVC 5

前端 未结 6 1099
粉色の甜心
粉色の甜心 2021-01-01 22:05

I am creating an ASP.NET Web Application in mvc5 and i made a model class with a controller. My application is running but when i want to access my moviescontroller in url l

6条回答
  •  时光说笑
    2021-01-01 22:48

    > Here EmployeeDetail is a table name and Employee is a model name.  And
    > ID,Branch,Salary and UID is a table field
    
    
      public ActionResult Index()
                    {
                        List employees = context.EmployeeDetails.ToList();
                        List emp = new List();
                        foreach(EmployeeDetail item in employees)
                        {
                            emp.Add(new Employee
                                {
                                    ID=Convert.ToInt32(item.ID),
                                    Branch=item.Branch,`enter code here`
                                    Salary=Conve`enter code here`rt.ToInt32(item.Salary),
                                    UID = Convert.ToInt32(item.ID),
                                });
                        }
                        return View(emp);
                    }
    
    
    
    >  view page code
    
    
        

    Index

      @foreach (var emp in Model) {
    • @Html.ActionLink(emp.Branch, "Details", new { id = emp.ID });
    • }

提交回复
热议问题