I've declare each subitem in the parent's model (as public virtual list or subitem) and created a property for each child that links back to the parent. e.g. in vehicle I have
publicvirtualAutoPolicy AutoPolicy { get; set; }
I get the error:
A specified Include path is not valid. The EntityType 'Phoenix.Models.AutoPolicy' does not declare a navigation property with the name 'Coverages'.
When I try to get information back from the details view. Here's the offending code:
Unless I'm missing something it seems to be saying there's no relationship in the EDMX for the two entities. There may be one in the DB, but not in the conceptual model.
Maeleki
Member
7 Points
16 Posts
"does not declare a navigation property with the name" on three level model.
Jun 19, 2012 02:40 PM|LINK
I have a model that has three levels:
AutoPolicy
Vehicle
Coverages
I've declare each subitem in the parent's model (as public virtual list or subitem) and created a property for each child that links back to the parent. e.g. in vehicle I have
public virtual ViewResult Details(int id) { AutoPolicy autopolicy = context.AutoPolicies.Include("Vehicles").Include("Coverages").Single(x => x.ID == id); return View(autopolicy); }BrockAllen
All-Star
28084 Points
4997 Posts
MVP
Re: "does not declare a navigation property with the name" on three level model.
Jun 19, 2012 02:44 PM|LINK
Unless I'm missing something it seems to be saying there's no relationship in the EDMX for the two entities. There may be one in the DB, but not in the conceptual model.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Maeleki
Member
7 Points
16 Posts
Re: "does not declare a navigation property with the name" on three level model.
Jun 19, 2012 02:48 PM|LINK
So how do I declare the relationship in the model?
BrockAllen
All-Star
28084 Points
4997 Posts
MVP
Re: "does not declare a navigation property with the name" on three level model.
Jun 19, 2012 02:53 PM|LINK
You're doing EF, right?
Generating Models and Mappings in EF
Defining and Managing Relationships in EF
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
tdykstra
Contributor
4523 Points
630 Posts
Microsoft
Moderator
Re: "does not declare a navigation property with the name" on three level model.
Jun 19, 2012 03:26 PM|LINK
Try this:
AutoPolicy autopolicy = context.AutoPolicies.Include("Vehicles.Coverages").Single(x => x.ID == id); return View(autopolicy);Maeleki
Member
7 Points
16 Posts
Re: "does not declare a navigation property with the name" on three level model.
Jun 19, 2012 07:20 PM|LINK
?that's it? it works!
... wow.
Thanks!