nacho10f
nacho10f

Reputation: 5886

How should I model this in EF?

My app is supposed to have Medics and Participants.

They are all supposed to be able to login to the Site.

So, right now what I have is this.

public class Participant:Person
{
      public string EmergencyContactNumber;
}

public class Medic:Person
{
   public string MedicHospitalId;
}

public abstract class Person
{
   public string FirstName;
   public string LastName;

   public string UserName; //this is the Membership Provider UserName to associate the MembershipUser to the Person thats logging into to the system.

}

The problem with this is that a Medic could eventually also be a Participant... and I dont want to have to create a new User for that.. How could I change my model to allow this feature?

Upvotes: 2

Views: 119

Answers (2)

Gengzu
Gengzu

Reputation: 542

Maybe roles will be good solution for you?

Upvotes: 0

nathan gonzalez
nathan gonzalez

Reputation: 11987

i'd redo it to be a 'has a' instead of an 'is a' relationship. so instead of a medic being a person, it would be related to a person, like :

public class Medic
{
   public string MedicHospitalId;
   public Person Person;
}

there would then be a medic table with a fk relationship with the person table. same thing for the participant. this would allow for a person to be both, and clean up the model a little i think.

if you wanted to get even more crazy with it, you could denormalize it into more of an eav table, but that's for another day.

Upvotes: 1

Related Questions