上次作过一个《Asp.net webform scaffolding结合Generic Unit of Work & (Extensible) Repositories Framework代码生成向导》 html
是生存Web Form的。git
此次看到网上有生成MVC Saffolding扩展原做者的代码 https://github.com/robinli/MVC5-Scaffoldergithub
我在他的基础上整合了Generic Unit of Work & (Extensible) Repositories Framework,而且添加分页和查询功能。web
Generic Unit of Work & (Extensible) Repositories Framework 下载地址 http://genericunitofworkandrepositories.codeplex.com/releases/view/113204ajax
Happy.Scaffolding.MVC5.vsix (源代码下载地址(https://github.com/neozhu/MVC5-Scaffolder) 若是以为好请点赞 :)bootstrap
Unitymvc
Unity bootstrapper for asp.net mvcapp
Demo程序 http://files.cnblogs.com/files/neozhu/mvcscaffoldingDemo.zipasp.net
Category,Product本身定义的实体对象工具
CategoryMetadata和ProductMetadata是经过向导生成主要用于验证和显示
建立metadata类的属性
工具会自动生成如下几个文件
Controller
----CategoriesController.cs
Repositories
---CategoryRepository.cs
Services
---ICategoryService.cs
---CategoryService.cs
View
---Categories
-----Insert.cshtml
-----Edit.cshtml
-----EditForm.cshtml
-----Create.cshtml
具体代码请看Demo程序
修改UnityConfig.cs
将须要用的Repository和Service注册进去
查询页面
编辑页面
删除功能
新增页面,若是有外键关联会自动生成select选择
新增修改采用popup的方式,单页面使用ajax form提交作到局部刷新
新增一对多的修改和新增页面
使用更多的ajax功能