简体   繁体   中英

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.

This gives a reasonable example of how to use the EF with the MVC framework. 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! Especially when compared to using 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.

FWIW, I've done a tiny bit of ASP MVC and I'm not sure you're going to like mixing the two.

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. 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.

To get started with the Entity Framework, your bet would be to take a look at the official ADO EF samples located (2) here. 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.

(1) [ http://blogs.msdn.com/efdesign/archive/2008/11/20/n-tier-improvements-for-entity-framework.aspx]
(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. Check it out here - We'd love to hear your feedback.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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