I have two class of Student and StudentAddress. Where a Student have one Address. Now How can I set the Primary key StudentId of the Student class as the Foreign key of the StudentAddress class using Fluent API. I want a different property such as StudentId will be the Foreign key in StudentAddress. How can i do this? (I am using Entity Framework 6). Here is my classes.
public class Student
{
public int StudentId { get; set; }
public string StudentName { get; set; }
//Navigation property
public virtual StudentAddress StudentAddress { get; set; }
}
public class StudentAddress
{
public int StudentAddressId { get; set; }
public int StudentId { get; set; } //Set this property as a forign key
public string Address { get; set; }
//Navigation property
public virtual Student Student { get; set; }
}