有没有办法在c#中自动生成Web API
问题描述:
有没有办法在c#中自动生成Web API。
我需要一种方法来自动生成webapi controller.cs。是否有任何工具或任何其他建议可以帮助
Is there any way to automatically generate Web API in c#.
I need to a way through which webapi controller.cs can automatically be generated. Is there any tool or any other suggestion will help
答
在MVC 5中,您可以使用模型类来构建Web API控制器。
请按照以下步骤操作:
1.右键单击Controllers并选择Web API 2 Controller使用实体框架。
2.单击添加按钮,提供模型类,数据库上下文和api控制器名称的名称。
3.单击添加按钮,然后单击添加按钮。将使用数据库表的CRUD方法生成API控制器。
希望这会有所帮助。
In MVC 5 you can scaffold Web API controller using your model class.
Please follow the steps below:
1. Right click on Controllers and Select Web API 2 Controller with actions, using Entity Framework.
2. Click Add button and provide the name of the model class, database context and api controller name.
3. Click Add button and the API controller will be generated with the CRUD methods for your database table.
Hope this will help.