简体   繁体   中英

.NET 4.0, MVC 2, Entity Framework 4, and Repository Pattern

I am new to both MVC as well as Entity Framework, but I want to do my next project using those technologies. I went through the NerdDinner tutorial at http://nerddinnerbook.s3.amazonaws.com/Part1.htm . NerdDinner uses Linq to Sql and uses the Repository pattern to manage data access. NerdDinner is written so well that I wanted to use it as my guide when working on my new project. Unfortunately, since it's using Linq to Sql, and the recommendation now is to use Entity Framework 4, I got thrown off a little. Since I am also new to MVC, I sort of need a good example like NerdDinner to start off with, and I'm unable to find something similar except that uses the EntityFramework 4.0.

If I start off using Linq to Sql with the repository pattern like NerDinner does, it should be pretty easy to switch to EntityFramework later right?

Are there any good tutorials using MVC 2 and EF 4?

There is an Entity Framework Nerddinner.com sample:

http://nerddinner.codeplex.com/releases/view/45621

Scott wrote a little bit on nerd dinner and the Entity Framework that may get you going.

There is also the mvc music store sample .

我喜欢EF4的这个教程,其中包含存储库模式: Testable Code

Yes, switching from Linq-To-SQL to Entity-Framework is mostly painless. I have built two very successfull web applications of sufficently higher complexity than NerdDinner using the NerdDinner tutorial as a guideline and have not found any issues with the design.

As you are new to MVC and EF then I'd suggest a tiered approach. Start with MVC and follow the NerdDinner example (although it's not a true repository or wasn't last time I looked), once you are comfortable with the MVC paradigm you should find it easy to move from Linq to SQL to EF.

Is nerd dinner really written well? Some people don't think so .

To answer the question -- you you've got a solid repository model, then upgrading from Linq2Sql to the current version of the entity framework is relatively painless. But I wouldn't want to try it without a solid test suite.

EF is not necessarily better than Linq to SQL, as you can see here . It depends on what you're trying to achieve.
But if you still prefer EF and don't find a good tutorial, I think learning it separately isn't such a bad option.

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