EntitySet 'Department' is based on type 'Admin' that has no keys defined

Viewed 5988

When I am accessing my Model's Data from a Controller. I got this error EntitySet 'Department' is based on type 'Admin' that has no keys defined. I am using MVC5 with visual stdio 2013 RC.

deptID (Primary key), deptName, Description : all are column name of Department table.

desgID (Primary key), desgName, description: all are column name of Designation table.

Objective :- I want to create a dialog box of deptName or desgName on the view page but now I want to resolve these issue.

I am referring these link :- EntityType 'Category' has no key defined. Define the key for this EntityType

ASP.NET MVC 3 EntityType has no key defined

but according these link. I am trying to use [Key] with my primary key column but it's not prompt in mvc5.

Model :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace mvcAppraisalSystem.Models
{
  public class Admin
 {
    public int deptID { get; set; }
    public string deptName { get; set; }
    public string Description { get; set; }
    public int desgID { get; set; }
    public string desgName { get; set; }
    public string description { get; set; }
}

 public class AdminDBContext : DbContext
 {
    public DbSet<Admin> Department { get; set; }

    public DbSet<Admin> Designation { get; set; }
 }
}
1 Answers
Related