1

I am planning to build a web application using ASP MVC3 that runs on Azure with a SQL Azure back end. I would like to use the Microsoft stack and have no plans to ever change to another stack. I am looking into the use of WCF and WF but that would be in the future.

I looked at the traditional and Code First approach to using Entity Framework but I can't see if there is any advantage in using one or the other approach. Sure they each have advantages but for me I don't care if my classes do inherit from EF classes. All I want is to find the most efficient solution.

Can anyone out there give me some advice as to which approach might be the best.

thanks very much

Richard

4 Answers4

1

This is really more of an opinion gathering question and probably belongs more to the Programmers site of StackExchange, but I'll take a stab:

I am definitely a traditional approach kind-of-a-guy. To me, data is key. It is most important. Various objects, layers, applications, services come, go and evolve. But data lingers on. Which is why I design my databases first. In my experiences, data has always been king.

Igorek
  • 15,716
  • 3
  • 54
  • 92
0

I'd go with Code First approach.

This great blog post by Scott Guthrie explains its advantages.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • Thanks for taking the time to reply and to add the link. I already read this along with just about everything else on CodeFirst. So many people saying how good it is but I am not sure any of that applies to my situation. What I would really like to know is what's the advantage in NOT using code first? – RichardAlanA Jan 09 '11 at 15:51
0

Code first for me also. If you suddenly started to hate Entity Framework and wanted to switch to NHibernate you will have a lot less work on your hands.

Also, there is a cleaner separation of concerns by totally isolating your domain layer from your data access layer.

I am not 100% sure it still applies, but I think the code generation, partial class malarky of entity framework can cause problems when testing.

Did I mention code first is a lot less hassle.

nick
  • 1,477
  • 2
  • 20
  • 29
0

Code First is an "Architecturally correct" approach, but reality tends to differ on these things when you have to consider effort, value, and speed of developement.

Using the "Model First" approach is much faster and easier to maintain. Database changes propagate with a simple right click "Regen from database", you don't get strange errors creeping into your code when you forget to change a property name or type.

Having said that you can have a bit of both with the the new POCO support in EF4. You can remove the dependencies on base classes while at the same time use the modelling tools:

A lot of good links in this thread:

Entity Framework 4 / POCO - Where to start?

Community
  • 1
  • 1
Doobi
  • 4,844
  • 1
  • 22
  • 17