views:

226

answers:

2

I'm learning ASP.MVC now. I got some problems of creating strong-typed view. I added Entity Data Model to Models, and then I tried to add a strong-typed view based on the Entity Data Model I created. But I cannot see any class in "View data class" in "Add View" dialog.

Did I miss sonmething?

A: 

Steps I did to do this were;

Create an entities data model in a new project under the solution.

Add some objects to the EDM using the model browser.

Make a model class in the Models folder of my MVC project, then add some method that gets objects from the Entity Data Model. Don't forget to reference you EDM project from your MVC project.

In my controller cerate a new ActionResult (or View Result), get it to call for it's objects from the models folder model. Then right click and create view...

You should see your entities data model and your models folder objects in the view data class dropdown. The reason for using the models folder, for me, is so that I can make it very clear when I am lazy loading objects, for instance, order items from a parent order.

Mark Dickinson
+1  A: 

Build your project before you add view.

Vikas