I have Following Entities in Application.
Student
Parent (This Parent can be Father/Guardian)
Address
They have following classes defined.
public Class Student
{
public int StudentId {get; set;}
//Addresses
public Address TemporaryAddress {get;set;}
public Address PermanentAddress {get;set;}
//Parent
public Parent Father {get;set;}
public Parent Guardian {get;set;}
}
public class Parent
{
public int ParentId {get;set;}
public string Name {get;set;}
//Addresses
public Address TemporaryAddress {get;set;}
public Address PermanentAddress {get;set;}
}
public class Address
{
public int AddressId {get;set;}
public string Country {get;set;}
public string State {get;set;}
public string Town {get;set;}
public string House# {get;set;}
}
And i want to have following sort of relationship between them
Student
->TemporaryAddress (Address)
->PermanentAddress (Address)
->Father (Parent)
->TemporaryAddress (Address)
->PermanentAddress (Address)
->Guardian (Parent)
->TemporaryAddress (Address)
->PermanentAddress (Address)
In other words,
Student has one TemporaryAddress and one PermanentAddress. Student has one Father and one Guardian (They both can be same i.e. a Guardian can be Father as well) Parent (Father/Guardian) has TemporaryAddress and PermanentAddress.
How can i acheive this using Fluent APIs of Entity Framework? What other fields needs to be added in Address and Parent Entities to make this relation possible.
Thanks.