Question
Let's say I have the model: public class Student { int StudentID {get;set;} string FirstName {get;set;} string LastName {get;set;} ICollection courses = {get; set;} }
Let's say I have the model:
public class Student {
int StudentID {get;set;}
string FirstName {get;set;}
string LastName {get;set;}
ICollection courses = {get; set;}
}
Another Model:
public class Course{
int CourseID {get;set;}
string CourseName {get;set;}
string CreditHours {get;set;}
}
One more Model
public class StudentCourse{
int StudentCourseID {get;set;}
int StudentID {get;set;}
int CourseID {get;set;}
}
Now I add a bunch of data to the database...
and the relationship between student to course (one to many) is lost.
That is now I only have three data tables based on the models above in the database
with no relationship between them whatsoever.
If I create another application, write 3 models matching exactly as the models above and define the one to many relationship between
student and course using fluent API, will that work? That is will I be able to relate the data that already exists?
For example,
After doing the step above and querying a list of student and doing student.courses.ToList(); will it return the list of courses for the particular student based on what is in the database already?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started