简体   繁体   English

实体框架和asp.net mvc

[英]entity framework and asp.net mvc

i search a good tutorial to learn how to use entity framework in the right manner. 我搜索一个很好的教程,学习如何以正确的方式使用实体框架。 in particular with asp.net mvc. 特别是asp.net mvc。

This gives a reasonable example of how to use the EF with the MVC framework. 给出了如何将EF与MVC框架一起使用的合理示例。 I have looked at this recently too and I am coming to the same conclusions as Rob, it is more pain than it is worth! 我最近也看过这个,我得出与Rob相同的结论,它比它的价值更痛苦! Especially when compared to using Linq2Sql. 特别是与使用Linq2Sql相比时。 Not having the same context when loading the entities as when you save them (typically different actions), causes a lot of unnecessary code to be written. 在加载实体时没有像保存它们时那样具有相同的上下文(通常是不同的操作),会导致编写大量不必要的代码。

I'd point you in the direction of this rather (1) lengthy article from the Entity Framework team. 我将向您指出实体框架团队这篇相当长篇文章的方向。

They've done a pretty good job of explaining both the shortcomings of the initial version (v1.0) and also give plenty of ideas into what they are considering for the next version. 他们在解释初始版本(v1.0)的缺点方面做得非常出色,同时也为下一版本的内容提供了大量的想法。

FWIW, I've done a tiny bit of ASP MVC and I'm not sure you're going to like mixing the two. FWIW,我做了一点ASP MVC,我不确定你会喜欢混合两者。

For the (v1.0) version of the Entity Framework you really need to either do one of two things - work with "disconnected" entity sets or retail the data context of an entity set. 对于实体框架的(v1.0)版本,您确实需要执行以下两项操作之一 - 使用“已断开连接”的实体集或零售实体集的数据上下文。 Either scenario has pitfalls as I'm sure you can appreciate. 这两种情况都有陷阱,因为我相信你可以欣赏。 In short.. I don't think there is a "right manner" to pick up at this stage. 简而言之......我不认为现阶段有“正确的态度”。 At least not with ASP MVC. 至少没有ASP MVC。

To get started with the Entity Framework, your bet would be to take a look at the official ADO EF samples located (2) here. 要开始使用实体框架,您可以在此处查看位于(2)的官方ADO EF样本 The easiest to pick up and start learning with, IMHO, are the WinForms based examples, but there are a few ASP.net examples which nmight be helpful. 最容易上手并开始学习,恕我直言,是基于WinForms的示例,但有一些ASP.net示例,它们可能会有所帮助。

(1) [ http://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx] (1)[ http://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx]
(2) [ http://code.msdn.microsoft.com/adonetefx] (2)[ http://code.msdn.microsoft.com/adonetefx]

We're currently working on an EF 4.0 Reference Implementation using ASP.NET MVC at the front end. 我们目前正在前端使用ASP.NET MVC进行EF 4.0参考实现。 Check it out here - We'd love to hear your feedback. 这里查看 - 我们很乐意听取您的反馈意见。

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

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