I'm creating a application using entity framework code-first and i'm facing some problems with the limitations of EF while following the interface segration principle.
public interface IProduct
{
int Id { get; set; }
ICollection<IProcess> Processes { get; set; }
ICollection<ILine> Lines { get; set; }
String Description { get; set; }
String Number { get; set; }
String Name { get; set; }
}
Problem is the Processes and Lines property cause it can't figure out which class in the concrete type (I presume).
I know that i could achieve almost the same by using abstract classes. Reason why i haven't just done this is that i find it wrong to change the model because of EF limitations.
What will be the best way to solve this? Any alternative to EF that allows interfaces as navigation property.
There is only one way to solve this - use concrete classes persisted to the database. EF doesn't support any other way. Even using abstract classes will not help you unless you map the whole inheritance tree (don't do that).
If you want property exposing an interface you must offer second non mapped property which will do the conversion from property exposing concrete type internally.
Simply if you want to use EF you must bend your architecture to follow its feature set.