HUGE EF4 Inheritance Bug
Posted
by djsolid
on ASP.net Weblogs
See other posts from ASP.net Weblogs
or by djsolid
Published on Wed, 28 Apr 2010 19:49:06 GMT
Indexed on
2010/04/28
19:58 UTC
Read the original article
Hit count: 621
Well maybe not for everyone but for me is definitely really important.
That is why I get straight into the point.
We have the following model:
Which maps to the following database:
We are using EF4.0 and we want to load all Burgers including BurgerDetails.
So we write the following query:
But it fails. The error is :
“The ResultType of the specified expression is not compatible with the required type. The expression ResultType is 'Transient.reference[SampleEFDBModel.Food]' but the required type is 'Transient.reference[SampleEFDBModel.Burger]'.Parameter name: arguments[0]”
So in the new version of EF there is no way to eager load data through Navigation Properties with 1-1 relationships defined in subclasses.
Here is the relevant Microsoft Connect Issue. It is described through an other example but the result is the same. Please if you think this is important vote up on Microsoft Connect.
EF 4.0 has many improvements. I am using it since v1 in large-scale projects and this version is faster,produces cleaner sql, more reliable and can be used for complicated business scenarios. That is why I believe this issue should be solved as soon as possible. I understand that release cycles are slow but I am hoping atleast for a hotfix.
I also have uploaded the example project so you can test it. Download it from here.
If anyone has found any workarounds please post it in the comments section.
Thanks!
© ASP.net Weblogs or respective owner