开发者

Is MVC 3 Scaffolding usable in n-layer applications?

I've seen some examples of ASP.NET MVC3 Scaffolding but those are always simple basic applications. What about layered/tiered solution with several Projects:

/Data  
/Repository  
/Services  
/UI (MVC3)  

The basic scaffolding pushes everything into the controller.

Can the scaffolding template be customized so it takes POCOs from Data project, then creates repository in a Repository project, services in a Service project and finally creates a thin controller in MVC that knows nothing about the data context?

I'm little confused because it's a real productivity boos开发者_StackOverflow社区ter.


If you use the -Repository flag, you get a repository. With the default templates, that goes in the Model folder (if using areas, it goes in the corresponding Area Model folder).

You can customise the templates that MvcScaffolding uses (see Steven Sanderson MVCConf2 video). However, to get things to go into separate projects, etc, is going to be difficult, if you have never used powershell script.

There is of course, nothing to stop you moving the files, renaming the namespaces, etc. Yes it takes a bit of work, but it is a lot better than nothing. I do it, it takes me all of 10 minutes.

I would expect someone will produce a NuGet package of that sort of thing soon, or else extra tooling to make it easier.

As you say, it is a productivity booster, but maybe you still just gotta do a bit yourself.


Check out the Nuget mvcscaffolding project - good blog posts at http://blog.stevensanderson.com/2011/04/08/mvcscaffolding-scaffolding-custom-collections-of-files/

You can customize this to be aware of whatever layers you want and surely can reference other repository based projects etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜