实体框架中使用存储过程中的错误?

问题描述:

我想在实体框架中使用此存储过程

i want use this store procedure in entity framwork

CREATE Procedure [dbo].[GetSood]
@datefrom nvarchar(15),
@dateto nvarchar(15)

as
SELECT Price,Numbers,PriceTotal FROM VW_Sale  WHERE DateCreate>=@datefrom and DateCreate<=@dateto  and IsSale=1 and PayType=2;



我在模型中添加了此过程,但是在运行时显示此错误



i add this procedure in model but when run show this error

The data reader is incompatible with the specified 'AriaSalesmanagmentModel.VW_Sale'. A member of the type, 'ID', does not have a corresponding column in the data reader with the same name.



我的代码是:



and my code is:

public List<dal.vw_sale> GetSood(string dateFrom, string dateTo)
        {
            DAL.AriaSalestEntities objAria = new AriaSalestEntities();

            var sood = from s in objAria.GetSood(dateFrom, dateTo) select s;
            return sood.ToList();
        }</dal.vw_sale>

通常,当存储过程返回的游标的列集与视图的列集不同时,就会出现此问题.
不同之处可能在于这些列的名称.请检查列名称在数据库和框架中是否相同.
检查您的框架是否有时会更新,Designer.cs不会对其进行更新.
This problem usually arises when the cursor returned by stored procedure has a set of columns that differs from the set of view''s columns.
The difference can be in names of these columns. Please check if the column name is the same in database and framework.
Check if your framework is updated sometimes Designer.cs will not update it.