开发者

advise how to implement a code generator for asp.NET mvc 2

开发者 https://www.devze.com 2022-12-26 18:40 出处:网络
I would like your advice about how best to solve my problem. In a Web server is running. NET Framework 4.0. Whatever the methods and technologies you would advise me. applications built on the basis

I would like your advice about how best to solve my problem.

In a Web server is running. NET Framework 4.0. Whatever the methods and technologies you would advise me. applications built on the basis Asp.NET MVC 2.

I have a database table in MS SQL Server. For each table in database, I must implement the interface for viewing, editing, and deleting. So code generator must generate model, controller and views.. Generation should happen after clicking on the button in WEB UI. as Model I use .NET Entity Framework.

Now,开发者_如何学运维 I need to generate controllers and views.

So if i have a table with name tableN1. and below its colums:

  • [ID] [bigint] IDENTITY(1,1) NOT NULL,
  • [name] [nvarchar 20] NOT NULL,
  • [fullName] [nvarchar 50] NOT NULL,
  • [age] [int] NOT NULL
  • [active] [bit] NULL

agree: if the type bit, then generate a checkbox. nvarchar (20) - textbox nvarchar (max)-textarea and so on.

for this table, i want to generate views and controller. thanks.

PS. solution for this problem must be FREE


You can use T4 Templates for this.

The Add Controller and Add View dialogs use this behind the scenes in ASP.NET MVC.


You could use CodeSmith or t4 templates


For anyone that needs to roll their own data layer PetaPoco (http://www.toptensoftware.com/petapoco/) includes a set of T4 templates that generate POCOs from a database and which can be used without implementing PetaPoco. You'll need to modify them to suit your purpose but it's significantly better than starting from scratch.

0

精彩评论

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

关注公众号