title: EntityFramework throwing Error : The table does not have a primary key defined
body: <p>I am using DatabaseFirst approach in Entity Framework, I am getting Error :</p>
  
  <blockquote>
    <p>The table does not have a primary key defined.</p>
  </blockquote>
  
  <p>Now, when I am Scaffolding for Controller it is giving me </p>
  
  <blockquote>
    <p>One or More Entities have Validation Error</p>
  </blockquote>
  
  <p>Must be because of the EF error has its effect in here.</p>
  
  <p>Earlier, when it was giving me the Primary Key error, I added column in table <code>StudentAddress</code> &amp; <code>StudentCourse</code> and make it <code>Primary KEY</code> just to get rid of the above Error. But added columns are not reflected back in my diagram(*.edmx), though in DB its reflecting back.</p>
  
  <p>DB Script is:</p>
  
  <pre><code>create table [Standard](
  
      StandardID int constraint pk_standard primary key,
      StandardName varchar(255),
      [Description] varchar(255)
  );
  
  
  create table Teacher(
      TeacherID int constraint pk_teacher primary key,
      TeacherName varchar(255),
      StandardID int constraint fk_teacher foreign key references [Standard](StandardID) ,
      TeacherType varchar(255)
  );
  create table Course(
      CourseID int constraint pk_course primary key,
      CourseName varchar(255),
      Location varchar(255),
      TeacherID int constraint fk_course foreign key references Teacher(TeacherID) ,
  );
  create table Student(
      StudentID int constraint pk_student primary key,
      StudentName varchar(255),
      StandardID int constraint fk_student foreign key references [Standard](StandardID) ,
  );
  create table StudentAddress(
      [Id] int constraint pk_SA primary key,
      StudentID int constraint fk_studentaddr foreign key references Student(StudentID) not null,
      Addr1 varchar(255),
      Addr2 varchar(255),
      City varchar (50),
      [State] varchar (50)
  );
  create table StudentCourse(
      [Index Number] int constraint pk_SC primary key,
      StudentID int constraint fk1_studentcourse foreign key references Student(StudentID) not null,
      CourseID int constraint fk2_studentcourse foreign key references Course(CourseID) not null,
  );
  </code></pre>
  
  <p>PS : Creating WebApp using WebApi2 and EF(for data).</p>