Unable to retrieve metadata for xyz.model.xxx in mvc

asp.net-mvc asp.net-mvc-5 c# entity-framework-6

Question

In mvc, I'm using the entity-framework. While generating the view, I keep getting this problem. With read/write actions, views, and an MVC controller, I'm utilising EF. I'm attempting to use the scaffold template to create a list.

This Entity Framework auto generated class

namespace WebApplication3.Models
{
    using System;
    using System.Collections.Generic;

    public partial class Employee
    {
        public int EmployeeId { get; set; }
        public string Name { get; set; }
        public string Gender { get; set; }
        public string City { get; set; }
        public Nullable<System.DateTime> DOB { get; set; }
        public Nullable<int> DepartmentId { get; set; }

        public virtual TblDepartment TblDepartment { get; set; }
    }
}

My controller code is as follows:

public ActionResult EmployeesByDep()
{
    var employees = db.Employees.Include("TblDepartment").GroupBy(x => x.TblDepartment.DepName)
        .Select(y => new TotalDepartments
        {
            DepName = y.Key,
            Total = y.Count()

        }
        ).ToList().OrderByDescending(y=>y.Total);
    return View(employees);
}

model number:

public string DepName { get; set; }
public int Total { get; set; }
1
0
2/12/2017 1:08:39 AM

Popular Answer

ZZZ_tmp
0
2/13/2017 6:50:16 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow