Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student
- {
- public int ID { get; set; }
- public string NAME { get; set; }
- public Course Course { get; set; }
- }
- public class Course
- {
- public int ID { get; set; }
- public string Name { get; set; }
- }
- | ID | Course |
- ------------------------
- | 1 | Math |
- -----------------------
- | 2 | Physics |
- -----------------------
- var student = new Student
- {
- Name = "ABC",
- Course = new Course { ID = 1, Name = "Math"}
- }
- context.Students.add(student);
- context.SaveChanges()
- context.Entry(student).State = EntityState.Added;
Add Comment
Please, Sign In to add comment