开发者

Can EntityObject be used to directly generate a view for various scaffolds?

When I add a strongly typed view I see my Entities listed in the Model class dropdown. But, if I select an entity and Scaffold, say List, I get a runtime error of object reference not set to an instance of an object.

In past projects I created a Service layer that called LINQ using CRUD. Then I consumed this service in my Controller and manually created the Views from the resulting service classes. It would be a lot easier if MVC just did all that for me.

Is it possible to directly create scaffold views from con开发者_运维问答crete classes inheriting EntityObject?


Simple answer : Yes.

I just tried the following test case...

New Project

Create EDMX

Build

Add Controller (With Read/Write actions and views using entity framework

pick Model class and context (the thing normally suffixed with 'entities'

click add

run - it works

EDIT: added MVC Scaffolding too...

open package manager

Install-Package MvcScaffolding

Add Controller (MVC Scaffolding controller With read/write actions & views using EF COde)

Build and Run : Also works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜