We need construct expression for EF in dynamic way. For example create test models:
public class TestBase
{
public int Id { get; set; }
}
public class T
Wow, this sounds like another EF Core bug (happens also in v.1.1.0 (release)).
The only difference between the two expressions is the ReflectedType of the property accessor expression Member.
You can fix it this way:
// ...
var p = e.Type.GetProperty("Id");
if (p.ReflectedType != p.DeclaringType)
p = p.DeclaringType.GetProperty(p.Name);
Expression bin = Expression.MakeMemberAccess(e, p);
// ...
but it's weird to have such requirement, I would suggest reporting the issue to EF Core GitHub.