EAV and linq is not a happy marriage. I think your best shot is to create an unmapped property in eav_attribute
that resolves the value (as object
) from it's typed attribute child. With entity framework, you won't be able to use this property in an expression (i.e. not in a Where
or Select
), You must convert to IEnumerable
first to access it. (Linq-to-sql may allow it because it can switch to linq-to-objects below the hood).
Another option is to create a calculated column of type sql_variant
that does the same, but now in t-sql code. But... EF does not suport sql_variant
. You've got to use some trickery to read it.
That's the reading part.
For setting/modifying/deleting values I don't see any shortcuts. You just have to handle the objects as any object graph with parents and children. In sql server you can't use cascaded delete because it can only be defined for one foreign key. (This may tackle that, but I never tried).
So, not really good news, I'm afraid. Maybe good to know that in one project I also work with a database that has an inevitable EAV part. We do it with EF too, but it's not without friction.