简体   繁体   English

根据数据库表定义自动生成代码?

[英]Auto-generate code based on database table definition?

Is it possible to automatically generate a simple form, using c# or javascript in asp.net, from a given database table definition?是否可以从给定的数据库表定义中使用 c# 或 asp.net 中的 javascript 自动生成一个简单的表单? To give you an example table testTable has columns userFirstName, userLastName, userAddress, userEmail and I want to take this definition and make a form that has a label and textbox for each of these columns of the table?给你一个例子表testTable有列userFirstName, userLastName, userAddress, userEmail ,我想采用这个定义并为表的每一列制作一个带有标签和文本框的表单? How would I even start to do this if it's possible.如果可能的话,我将如何开始这样做。 Thank you in advance for your help.预先感谢您的帮助。

Well asp.net MVC scaffolding is your best tool then那么 asp.net MVC 脚手架是你最好的工具

Check out this article for tutorial:查看这篇文章以获取教程:

http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/ http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/

For pay: ASPRunner.NET付费: ASPRunner.NET

For free: I would recommend using Entity Framework to generate domain objects from your database and then you could use those domain objects as model classes in ASP.NET MVC, which provides for UI scaffolding.免费:我建议使用实体框架从您的数据库生成域对象,然后您可以将这些域对象用作 ASP.NET MVC 中的模型类,它提供了 UI 脚手架。

我更喜欢开源实用程序https://github.com/wsq003/DapperHelper它可以从数据库表生成 C# 类和 CRUD SQL 脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM