none
Entity Framework... Jump on board? RRS feed

  • Question

  • I'm a student in programming and web development. So far I've always created my own data access layers which communicate with the database by loading up parameters and calling a sproc, then return a datatable/reader/etc... Now that I've started messing around with ASP.NET MVC with EF & Code First, I'm wondering if it's worth it. I like the way I've been taught and I understand it pretty good, but I also like the RAD that comes with the other option. One thing I don't like is that it seems every time I start to grasp certain ways of doing things, there's something new that comes out and I need to start all over again. 

    I'd like to know which way is going to be most common I guess, and go that route. I like the idea of something new as well. But I feel I have less control over what's going on. I'm used to designing the database and writing the stored procedures and using my DAL to call back the info I require. To me, it seems to work in all situations and allows great flexibility. Now I haven't been doing this for long so I may be wrong as well.

    If I choose to learn EF what sort of limitations will I have? Also, is Code First worth getting into? I'm not talking for simple web applications. Basically I'm prepping myself to develop an ecommerce solution for auto parts sales. Typically like the ones you see where you select your make/model/year and then the categories of available parts are listed and each category holds a list of parts, etc... 

    What are your thoughts?

    Friday, December 23, 2011 8:15 PM

Answers

  • EF provides a HUGE benefit in terms of productivity.  You're trading some of the fine grained control for a large productivity boost and a lot of consistency.

     

    While, technically, you can do anything with a hand written DAL that you'd do with EF, the fact that it's so easy to write queries that are specific to a task at hand is a huge benefit.  In practice, this tends to mean that you get better use of your database resources, since hand written solutions tend to return more results than necessary in order to promote code reuse, etc.

     

    Code First is nice from a developer's standpoint.  It provides a bit more control over the process and a nicer development scenario (in my opinion) than the previous methods.

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 23, 2011 9:33 PM
  • No - you don't need to drop and recreate a database to make a change.... You need to adjust your code, of course, but it should work.

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 23, 2011 9:48 PM

All replies

  • EF provides a HUGE benefit in terms of productivity.  You're trading some of the fine grained control for a large productivity boost and a lot of consistency.

     

    While, technically, you can do anything with a hand written DAL that you'd do with EF, the fact that it's so easy to write queries that are specific to a task at hand is a huge benefit.  In practice, this tends to mean that you get better use of your database resources, since hand written solutions tend to return more results than necessary in order to promote code reuse, etc.

     

    Code First is nice from a developer's standpoint.  It provides a bit more control over the process and a nicer development scenario (in my opinion) than the previous methods.

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 23, 2011 9:33 PM
  • From what I've experienced so far, it seems the database must be dropped and recreated just to make a change. To me, it's a disaster waiting to happen in the long run. Is there something I'm missing or is this just how it is? How can you adjust as a project progresses and requires such changes when your database contains huge amounts, or any amount of data without having to back it all up and re-entering it? Perhaps I'm missing something though.
    Friday, December 23, 2011 9:39 PM
  • No - you don't need to drop and recreate a database to make a change.... You need to adjust your code, of course, but it should work.

     


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Friday, December 23, 2011 9:48 PM
  • From what I've experienced so far, it seems the database must be dropped and recreated just to make a change. To me, it's a disaster waiting to happen in the long run. Is there something I'm missing or is this just how it is? How can you adjust as a project progresses and requires such changes when your database contains huge amounts, or any amount of data without having to back it all up and re-entering it? Perhaps I'm missing something though.
    @EF 4.1 , in the generating database from model , use the option "Generate Migration T-SQL"
    Sunday, December 25, 2011 11:52 AM