实体框架存储过程映射帮助!
看来我对实体框架的欣赏受到了严重打击。 “MS 几乎做对了,但他们只是因为一些蹩脚的东西而错过了它”的想法即将出现。直到今天一切都很好。由于某些未知的原因,它将不再编译并出现错误 2048。我已经阅读了此内容,并且了解了如何需要映射所有三个操作。为什么这是必要的?如果我不需要删除功能而只需要插入和更新怎么办?我尝试将虚拟 SP 映射到我的删除函数。如果这能解决我的问题,无论多么俗气,都可以。唯一的问题是,它只会造成更多问题。
这就是我所拥有的。我正在 MVC 中编写一个简单的新闻通讯应用程序。我有一个出版物、问题和文章的实体,全部都是从我的数据库(SQL 08)生成的。我在数据库中设置了关系,它们很好地转换为我的 EDMX。我制作了一些 SP 来插入和更新我的问题和文章。我将它们添加到 EDMX 并相应地映射它们。我不需要它们中的任何一个的删除功能,也不需要发布实体的任何内容。为什么编译器强迫我映射所有函数? IMO,这是 EF4 的一个非常非常大的问题,我不敢相信 MS 会发布这样的垃圾。
另一个奇怪的问题是我尝试将 sp 映射到另一个项目中的实体,并仅配置插入和更新,并且它们编译得很好。为什么编译器不一致?
我宁愿不使用导入函数。这是我唯一的选择吗?如果是这种情况,它将消除 SaveChanges 方法的功能。加油MS!!!解决这个问题!!!!!!!
Seems my appreciation for the Entity Framework is taking a serious hit. The "MS almost got it right, but they just missed it because of something L-A-M-E" thought is coming up. Until today everything has been fine. For some unknown reason, it won't compile anymore with Error 2048. I've read up on this and I've seen how you need to map all three operations. Why is this even necessary? What I if I don't need a delete function and only need insert and update? I tried mapping a dummy SP to my delete function. If that fixes my problem, however cheezy, fine. Only problem is, it just created more problems.
Here's what I have. I'm writing a simple newsletter app in MVC. I have entities for a publication, issue and article all generated from my DB (SQL 08). I set up the the relationships in my DB and they translated fine to my EDMX. I made some SPs to insert and update my issues and article. I added them to the EDMX and mapped them accordingly. I don't need a delete function for any of them and I don't need anything for the publication entity. Why is the compiler forcing me to map all functions? IMO, this a MAJOR, MAJOR PROBLEM with EF4 and I can't believe MS would release it with this kind of crap coming up.
The other strange issue is I've tried mapping sp's to entities in another project and configured with only insert and update and they compile fine. Why is the compiler inconsistent?
I would rather not resort to having to use the Imported Functions. Is that my only option? If that's the case it eliminates the ability to the SaveChanges method. Come On MS!!! Fix this!!!!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过大量挖掘和并排文本比较,我想我已经找到了解决方案。
有问题的 SP 的设置就像
它应该是这样的
现在,我仍然不知道为什么 EF4 甚至需要这个,因为我没有更新问题 ID 并且错误消息对诊断问题几乎没有帮助。我的 SP 甚至不使用 IssueID,但 EF 无论如何都需要它。希望这能帮助某人。对于这方面的需求,微软仍然可以做得更好。
After much digging and side by side text comparison, I think I have found the solution.
The SP in question was set up like
where it should have been something like
Now, I still don't know why EF4 even requires this since I'm not updating the issueid and the error message lends little help in diagnosing the problem. My SP doesn't even use the IssueID, but EF needs it regardless. Hopefully this will help someone down the road. MS still could do a better job regarding the need for this.