Reputation: 27996
I am working in an asp.net MVC 4 application and I am using Entity framework 6 in my application. I am using both code first approach for new tables/entities as well as database first approach with model designer(edmx). Customers are in codefirst model with separate context where as vehicles are in edmx. both have different context object. I want to use a query like this:
return View(maindb.Reservations.Include("customer").Include("Vehicle"));
but it returns error:
A specified Include path is not valid. The EntityType 'myproject.Data.Reservation'
does not declare a navigation property with the name 'Vehicle'.
Please suggest how to fix it so that I can get properties of Vehicle and use them in my view.
Upvotes: 0
Views: 673
Reputation: 37770
I am using both code first approach for new tables/entities as well as database first approach with model designer(edmx)
Wrong way to go.
Please suggest how to fix it
Put those entities into the same context. You need to choose which approach is more suitable for you. For example, code first works as well with existing tables. If your tables don't match the naming conventions, you can easily override them with data annotations or fluent API, which is very flexible (see http://msdn.microsoft.com/en-us/data/jj591617 and http://msdn.microsoft.com/en-us/data/jj591620).
Upvotes: 1