A question about entities, roles and interfaces in Entity Framework 4.

Posted by mvole on Stack Overflow See other posts from Stack Overflow or by mvole
Published on 2010-05-14T09:46:34Z Indexed on 2010/05/14 13:14 UTC
Read the original article Hit count: 218

Hi,

I am an experienced .NET developer but new to EF - so please bear with me. I will use an example of a college application to illustrate my problem. I have these user roles:

Lecturer, Student, Administrator.

In my code I envisage working with these entities as distinct classes so e.g. a Lecturer teaches a collection of Students. And work with 'is Student' 'TypeOf' etc.

Each of these entities share lots of common properties/methods e.g. they can all log onto the system and do stuff related to their role.

In EF designer I can create a base entity Person (or User...) and have Lecturer, Student and Administrator all inherit from that.

The difficulty I have is that a Lecturer can be an Administrator - and in fact on occasion a Student can be a Lecturer.

If I were to add other entities such as Employee and Warden then this gets even more of an issue.

I could presumably work with Interfaces so a person could implement ILecturer and IStudent, however I do not see how this fits within EF.

I would like to work within the EF designer if possible and I'm working model-first (coding in C#).

So any help and advice/samples would be very welcome and much appreciated.

Thanks

© Stack Overflow or respective owner

Related posts about entity-framework-4

Related posts about entity-framework