asp.net mvc 4 - A specified Include path is not valid. The EntityType '' does not declare a navigation property with the name '' -


i wonder if help. above error when call .include(). breaks when include tblmemberships.

this.dbcontext.configuration.lazyloadingenabled = false; list<tblcustomerinfo> customers = this.dbcontext.tblcustomerinfoes.include("tblusers").include("tblmemberships").tolist(); 

the reason because navigation property between tblcustomerinfo , tblmemberships not exist. tblusers link between other 2 tables.

customer -- 1:* -- user -- 1:* -- membership 

(sorry, can't include image reputataion < 10).

my questions are:

  1. what need in order have tblmemberships included?
  2. is recommended way of retrieve data or should break 2 queries? or design totally rubbish?

i using ef5, asp .net mvc 4

kindly advise. thank you.

when write code this:

db.parenttable     .include("childtable")     .include("childofchildtable"); 

you saying include entries childtable keyed parenttable , include entries childofchildtable keyed parenttable. instead need tell entity framework childofchildtable beneath childtable in hierarchy, this:

db.parenttable     .include("childtable.childofchildtable"); 

so means code should be:

this.dbcontext.configuration.lazyloadingenabled = false; list<tblcustomerinfo> customers = this.dbcontext.tblcustomerinfoes                                       .include("tblusers.tblmemberships") 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -