I have the Student
, Course
and a relationship between them as StudentCourse
. The fields in these classes are as follows:
public class Student
{
public int StudentId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int CourseId { get; set; }
[ForeignKey("CourseId")]
public Course Course { get; set; }
}
public class Course
{
public int CourseId { get; set; }
public string CourseName { get; set; }
}
public class StudentCourse
{
public int ID { get; set; }
public virtual Student Student { get; set; }
public virtual Course Course {get;set;}
}
When I delete the students in student
table , then I want to remove the corresponding rows from the relationship StudentClass
. How can I do it?