What is the best way to create a one to many relationship between two objects where one is a generic type? Is it even possible? What I mean is the following:
I have a Project object and the project can have multiple invoice dates
public class Project
{
//...
public List<DateTime> InvoiceDates;
//...
}
I would like it to end up with one to many relationship in the Database. Do I have to wrap the DateTime object into my own object and define the navigation properties to have it created?
Yes. Entities must be reference types ( =
class) andDateTimeis astruct.List<DateTime>is also not a primitive type which could be mapped to a column type in the database. So, you can only create an entity for this with its own table and a one-to-many relationship.