使用实体框架设置的 NerdDinner 中缺少方法
我开始在 Wrox Press 的“Professional ASP.Net MVC 2”一书的帮助下学习 ASP.Net MVC 框架。它通过构建 NerdDinner Web 应用程序的示例介绍了该框架。一开始很顺利,我完成了它描述的每一步,设置数据库表和实体框架映射。
现在我到了它向我展示如何为此应用程序创建存储库类的部分。这就是我被困住的地方。它给出了 Add
方法的代码,如下所示:
public void Add(Dinner dinner) {
entities.Dinners.AddObject(dinner);
}
问题是我没有 AddObject
方法,或任何包含单词 Add 或 Insert 或任何的方法该主题的变体。删除也有同样的问题。起初我以为这本书可能假设了 .Net 4 和 VS 2010,但我再次检查了这本书的章节,它明确表示支持 VS 2008(所有版本)和 .Net 3.5。我使用 MS Web Installer 安装了 MVC 2.0,并使用 MS SQL Server Express 2008 R2 作为后端。
我可能会错过什么?我希望这只是他们在书中忘记提及的一些参考。
I am starting to learn the ASP.Net MVC framework with the help of the "Professional ASP.Net MVC 2" book from Wrox press. It introduces the framework by example of building the NerdDinner web application. It was smooth sailing at the beginning, I did every step it has described with setting up the DB tables and the Entity Framework mapping.
Now I got to the part where it shows me how to create the repository class for this app. And this is where I'm stuck. It gives the code for the Add
method as follows:
public void Add(Dinner dinner) {
entities.Dinners.AddObject(dinner);
}
The problem is that I don't have the AddObject
method, or any method that contains the words Add or Insert or any variation on that theme. Same problem with Delete. At first I thought the book might have been assuming .Net 4 and VS 2010, but I checked the book into section again, and it explicitly says that VS 2008 (all editions) and .Net 3.5 are supported. I have MVC 2.0 installed using the MS Web Installer, and MS SQL Server Express 2008 R2 as the back-end.
What could I be missing? I hope it's just some reference that they've forgot to mention in the book.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AddObject 是
ObjectSet
类在System.Data.Entity< 中定义/代码> 汇编。
AddObject is a method on the
ObjectSet<TEntity>
class defined in theSystem.Data.Entity
assembly.