I am planning a simple two table structure:
1) Teacher Table :
public class TeacherAccount
{
[DataType(DataType.Text), Required()]
public string Name { get; set; }
[DataType(DataType.Text), Required()]
public string Address { get; set; }
[DataType(DataType.EmailAddress), Required(), Key]
public string Email { get; set; }
[DataType(DataType.Password), Required()]
public string Password { get; set; }
[DataType(DataType.Password), Compare("Password"), Required(), NotMapped]
public string ConfirmPassword { get; set; }
public bool Activated { get; set; }
}
2) Subjects taught by a teacher :
public class Teacher_Subject_Map
{
[ForeignKey("TeacherAccount")]
public string Email { get; set; }
public string Subjects;
}
My Concept is : For email identifying a teacher, there can be multiple subjects, which is taught by that teacher.
How ever I am getting this :
The ForeignKeyAttribute on property 'Email' on type 'xpertsdesk.Models.Teacher_Subject_Map' is not valid. The navigation property 'TeacherAccount' was not found on the dependent type 'xpertsdesk.Models.Teacher_Subject_Map'. The Name value should be a valid navigation property name.
as error in mvc5.
What I am trying to do :
Create table Teacher(Email varchar(30) Primary Key, Other Details);
Create table Subjects(Email varchar(30) References Teacher(Email), Subject varchar(30));
What am I doing wrong ?