Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace MVCEF.Models
{

    public class StudentContext : DbContext
    {
        public DbSet<StudentModel> Students { get; set; }

    }
    public class StudentModel
    {
        [Key]
        public int Roll_No;
        //public int Roll_No { get; set; }
        public string Name { get; set; }
        public string Mobile_No { get; set; }
        public string City { get; set; }
    }
}


this is my model class.when i m trying to add a controller in
model class :StudentModel (MVCEF.Models)
and datacontext file :StudentContext (MVCEF.Models)

it give me the following error

System.Data.Entity.Edm.EdmEntityType has no key defined

plz help me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900