I'm using Asp.Net WebApi Odata V4 with Entity Framework 6. I'm trying to expand navigation property of a derived class, but im getting below error.
Base Entity
public abstract class BaseEntity
{
[ForeignKey("CreatedUser")]
public string CreatedBy { get; set; }
public virtual User CreatedUser { get; set; }
}
Entity
public class Book: BaseEntity
{
public int BookId {get;set;}
}
Odata Model Builder
builder.EntityType<BaseEntity>();
builder.EntitySet<Book>("Books");
Odata Query
http://localhost/svc/Books(1)?$expand=CreatedUser
Error:
The 'TypeAs' expression with an input of type 'App.Models.Book' and a check of type 'App.Models.BaseEntity' is not supported. Only entity types and complex types are supported in LINQ to Entities queries.
How can I overcome this issue?
BaseEntity
. – Gert ArnoldBaseEntity
– Rahul