简体   繁体   English

EF 5,存储过程和脚手架

[英]EF 5, Stored Procedures and Scaffolding

I have a stored procedure already in the database, I create an Entity Data Model, select the stored procedure, import into entity model is selected. 我已经在数据库中有一个存储过程,我创建一个实体数据模型,选择该存储过程,选择导入到实体模型中。 After creation go to model browser, double click on stored procedure under Function Imports and update complex types. 创建后转到模型浏览器,双击“函数导入”下的存储过程并更新复杂类型。 Everything seems fine. 一切似乎都很好。

Right click folder, add new scaffolding, select SP under Model Class, click add and get the following error: 右键单击文件夹,添加新的脚手架,在“模型类”下选择“ SP”,单击“添加”并得到以下错误:

在此处输入图片说明

Is scaffolding available with stored procedures? 存储过程中是否可以使用脚手架? If so, what is missing? 如果是这样,缺少什么?

Thanks!! 谢谢!!

Here is what you can do : 您可以执行以下操作:

  1. Add a empty 2.0 web api controller 添加一个空的2.0 Web API控制器
  2. Add using YourProjectName.Models using YourProjectName.Models添加
  3. Add this code for your newly created controller. 为您新创建的控制器添加此代码。

     public IHttpActionResult Get(string Id) { dbEntities db = new dbdbEntities(); var record = db.sp_yourStoreProcedure(Id); if (record == null) { return NotFound(); } return Ok(record); } 
    1. Run and test with http://localhost :{port}/api/{controller}/{id} 使用http:// localhost :{port} / api / {controller} / {id}运行和测试

*{controller}: controller name without the 'controller' part RepresasController = Represas * {controller}:不带“ controller”部分的控制器名称RepresasController = Represas

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

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