I have the following classes:
public class Project
{
public int ID { get; set; }
public string Name { get; set; }
...
// Navigation
public virtual IEnumerable<Task> Tasks { get; set; }
//public virtual IEnumerable<Message> Messages { get; set; } // ???
}
public class Task
{
public int ID { get; set; }
public int ProjectID { get; set; }
public string Name { get; set; }
...
// Navigation
//public virtual IEnumerable<Message> Messages { get; set; } // ???
}
public class Message
{
public int ID { get; set; }
public string Comment { get; set; }
...
// Foreign Keys ??
}
Basically:
- Project will have many Task
- Project will have many Message
- Task will have many Message
- Each Message will belong to either a Project or Task
How will I write the database, as well as write the EF code to achieve this? I want to be able to use Linq syntax for eg. List<Message> messages = project.Messages.ToList();
I have found this alternative design but not sure how the navigation properties will look.