Witam, chciałbym utworzyć relacje pomiędzy tabelami w mojej aplikacji MVC. Korzystam z Entity Framework. Mam już prototyp jakby to miało wyglądać i chciałem prosić Was o opinie czy to będzie w ogóle działać, co mam zmienić.
W mojej aplikacji mam trzy klasy pomiędzy którymi chciałbym utworzyć relacje. Są to:
- UserProfile
public class UserProfile
{
public string UserID {get; set;} //PK
public string UserName {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
public virtual List<Service> Services {get; set;}
public virtual List<VisitDetails> visitDetails {get; set;}
}
- Service
public class Service
{
public int ServiceID {get; set;} //PK
public string Name {get; set;}
public string Category {get; set;}
public string Description {get; set;}
public decimal Price {get; set;}
public virtual List<UserProfile> UserProfiles {get; set;}
public virtual List<VisitDetails> visitDetails {get; set;}
}
- VisitDetails
public class VisitDetails
{
public int VisitID {get; set;} //PK
//public string LoginUser {get; set;} ?
public string Date {get; set;}
public int ServiceID {get; set;} //- ForeignKey
public virtual Service service {get; set;}
public int UserID {get; set;} //- ForeignKey
public virtual UserProfile userProfile {get; set;}
}
Tak to wygląda graficznie.
Chodzi tutaj o rejestracje użytkowników. Zarejestrowany użytkownik(UserProfile) wybiera sobie usługę która mu odpowiada(Service), następnie wybiera termin i się na nią rejestruje(VisitDetails).
P.S proszę o wyrozumiałość.. Nigdy wcześniej tego nie robiłem.