views:

57

answers:

0

I am trying to setup a project using Entity Framework 4, POCO, and Code-Only.

Is it possible in entity framework for type of a navigation property to be an interface?

I have a "Task" class. A Task can be assigned to a user or a group each of which are represented by a separate class and stored in separate tables. The classes look something like this:

public class User : IAssignable
{
    public String Name { get; set; }
    public int ID { get; set; }
    public String Email { get; set; }
    public String Password { get; set; }
}

public class Group : IAssignable
{
    public String Name { get; set; }
    public int ID { get; set; }
    public String Manager { get; set; }
    public String Department { get; set; }
}

public class Task
{
    public String Title { get; set; }
    public DateTime DueDate { get; set; }
    public String Details { get; set; }
    public IAssignable AssignedTo { get; set; }
}

Is there a way to may the AssignedTo property as a navigation property in entity framework? I assume there will have to be some type of discriminator for EF to know if it needs to look in the Users table or the Groups table but I can figure out the mapping using Code-Only or EDMX.