【发布时间】:2012-02-09 00:11:18
【问题描述】:
我在导入存储过程然后创建复杂类型并将函数命名为 import "sproc_Forums_GetForumGroupByID" 后收到此错误,一旦选择了 GridView,此过程就会从 ObjectDataSource 获取单个论坛。我在 ExecuteReader 的行上得到错误。我已经有一个与实体框架一起使用的存储过程,并且它运行良好我不明白当我开始我的第二个过程时出了什么问题
EntitySet 'sproc_Forums_GetForumGroupByID' 未在 EntityContainer 'CMSEntities' 中定义。靠近简单标识符,第 1 行,第 13 列。
public class Forums
{
public Forum GetForumGroup(int ForumGroupID)
{
using (EntityConnection conn = new EntityConnection("name=CMSEntities"))
{
conn.Open();
EntityCommand cmd = new EntityCommand("CMSEntities.sproc_Forums_GetForumGroupByID", conn);
cmd.Parameters.AddWithValue("ForumGroupID", ForumGroupID);
using (EntityDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow))
{
/*
Forum forum = null;
int forumID = (int)reader[0];
string addedBy = reader[1].ToString();
DateTime addedDate = (DateTime)reader[2];
string title = reader[3].ToString();
string updatedBy = reader[4].ToString();
DateTime updatedDate = (DateTime)reader[5];
bool active = (bool)reader[6];
forum = new Forum(forumID, addedBy, addedDate, title, "", 0, 0, false, "",
updatedBy, updatedDate, active, "", 0, "", DateTime.Now, "");
return forum;*/
}
return null;
}
}
}
【问题讨论】:
-
检查您的实体模型(.edmx 文件)以验证您的存储过程是否存在。
标签: c# asp.net entity-framework