0

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.

Amit
15.4k8 gold badges49 silver badges69 bronze badges
asked Dec 17, 2013 at 5:38
0

1 Answer 1

1

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).

answered Dec 17, 2013 at 5:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.