none
Is it a right choice to use Entity Framework 4.0? RRS feed

  • Question

  • We are working on a quite big project written in WPF and WCF. The structure of the database contains about 60 tables, lots of stored procedures, views and some functions. We are not using any ORM at the moment. Some time ago when the first version of EF was release we did not go with it because of the known reasons:

    • one threaded only (it uses only one processor core)
    • no support for lazy loading
    • no support for POCO
    • horrible designer
    • no support for foreign keys (as far as I remember)
    • horrible mappings support (as far as I remember I needed to use lots of hacks and workarounds)

    I think we can all agree that this version of EF was not a good tool. I remember that calling SaveChanges() method on my entity model with a complex hierarchy took quite long time and looking at SQL Profiler I was confused seeing "SQL queries explosions". Therefore we decided to use repository pattern and repository locator pattern and write plain ADO.NET queries. This works fine so far, however sometimes we see that code maintence is hard. Additionally we use our own deserializers to materialize objects. At the moment we think about using Entity Framework 4.0. I know there are many improvements and enhancements in this framework and it's fine to use it in small projects. Therefore my question are:

    • what are pros and cons using EF 4.0 and what will be the consequence of using it in a bigger project?
    • how about SQL Queries generated by EF 4.0? Is the performance increased?
    • can EF 4.0 use all processor cores?
    • should we use it now or wait for EF 5.0 where Code first will be supported?

    • Edited by niao Tuesday, September 20, 2011 11:14 AM
    Tuesday, September 20, 2011 11:14 AM

Answers

  • On 9/20/2011 10:37 AM, niao wrote:
    >     On 9/20/2011 9:49 AM, niao wrote:
    >      > Thank for the answer,
    >      >
    >      > I cannot use other ORM than Entity Framework. The policy of the
    >     company
    >      > is: "Entity Framework or nothing - but is EF good enough to use
    >     it?. If
    >      > the performance is weak, then why should we use it instead of
    >     plain ADO.NET?
    >      >
    >      > The case is that I read Julia Lerman's book about Entity Framework 4
    >      > (second edition). She tries to convince the reader that he/she
    >     should go
    >      > for it and use it.She write about improvements and enhancements.
    >     I can
    >      > even say that she conviced me to go for it but on the other hand
    >     I have
    >      > a perception that it's not as good tool as she describe it -
    >     however it
    >      > can work fine for small/medium projects but I am afraid it's not
    >     going
    >      > to prove oneself
    >      >
    >      >
    >      >
    >      >
    >     I have to disagree since I was using EF on a big project for the
    >     military with lots of users hitting the databases through EF on the
    >     backend through WCF.
    >
    > Well, thanks for the answer. It seems to be a good news. Were you
    > satisfied with the queries performance? Was it EF4 or other version?
     
    Query performance is based what you know how to do and what not to do
    when doing Linq queries. Some of it I have shown you. I would hope you
    are using MS-SQL No lock in your T-SQL queries. But on the other hand,
    you don't implement No Lock  in EF queries could lead to performance
    issues as an example.
     
     
    I was using EF 3.5 at the time
     
     
    <copied>
     
    Because Entity SQL query commands are cached, later executions of the
    same query take even less time.
     
    <end>
     
    A lot of times, I was using Entity SQL for querying.
     
     
    Tuesday, September 20, 2011 3:02 PM

All replies

  • On 9/20/2011 7:14 AM, niao wrote:
    > We are working on a quite big project written in WPF and WCF. The
    > structure of the database contains about 60 tables, lots of stored
    > procedures, views and some functions. We are not using any ORM at the
    > moment. Some time ago when the first version of EF was release we did
    > not go with it because of the known reasons:
    >
    >   * one threaded only (it uses only one processor core)
    >   * no support for lazy loading
    >   * no support for POCO
    >   * horrible designer
    >   * no support for foreign keys (as far as I remember)
    >   * horrible mappings support (as far as I remember I needed to use lots
    >     of hacks and workarounds)
    >
    > I think we can all agree that this version of EF was not a good tool. I
    > remember that calling SaveChanges() method on my entity model with a
    > complex hierarchy took quite long time and looking at SQL Profiler I was
    > confused seeing "SQL queries explosions". Therefore we decided to use
    > repository pattern and repository locator pattern and write plain
    > ADO.NET queries. This works fine so far, however sometimes we see that
    > code maintence is hard. Additionally we use our own deserializers to
    > materialize objects. At the moment we think about using Entity Framework
    > 4.0. I know there are many improvements and enhancements in this
    > framework and it's fine to use it in small projects. Therefore my
    > question are:
    >
    >   * what are pros and cons using EF 4.0 and what will be the consequence
    >     of using it in a bigger project?
     
    I have used EF 3.5 in large projects with EF setting on the backend of
    WCF Web services.
     EF was using complied views, complied queries and (MS-SQL No Lock in a
    Transaction scope) when querying for better query performance. In
    addition, EntitySQL was also being used with a datareader. You can use
    query plan caching with Entity SQL.
     
    >   * how about SQL Queries generated by EF 4.0? Is the performance
    >     increased?
     
     
    >   * can EF 4.0 use all processor cores?
     
    don't know
    >   * should we use it now or wait for EF 5.0 where Code first will be
    >     supported?
    >
    >
     
    There is also nHibernate a more mature ORM solution.
     
     
    Also when saving entities in EF 3.5, I was able to expose the primary
    and foreign-key properties in the entities and basically took over
    inserting, updating and deleting entities based on associations with me
    populating the foreign-key properties and doing individual SaveChanges()
    within a Transaction.Scope.
     
    I thought it made the SaveChanges() faster instead of letting EF follow
    complex hierarchy. EF4 model generation has a check box to allow the
    exposure of the all key properties in the entity.
     
     
    Tuesday, September 20, 2011 1:25 PM
  • Thank for the answer,

    I cannot use other ORM than Entity Framework. The policy of the company is: "Entity Framework or nothing - but is EF good enough to use it?. If the performance is weak, then why should we use it instead of plain ADO.NET?

    The case is that I read Julia Lerman's book about Entity Framework 4 (second edition). She tries to convince the reader that he/she should go for it and use it.She write about improvements and enhancements. I can even say that she conviced me to go for it but on the other hand I have a perception that it's not as good tool as she describe it - however it can work fine for small/medium projects but I am afraid it's not going to prove oneself




    • Edited by niao Tuesday, September 20, 2011 1:53 PM
    Tuesday, September 20, 2011 1:49 PM
  • On 9/20/2011 9:49 AM, niao wrote:
    > Thank for the answer,
    >
    > I cannot use other ORM than Entity Framework. The policy of the company
    > is: "Entity Framework or nothing - but is EF good enough to use it?. If
    > the performance is weak, then why should we use it instead of plain ADO.NET?
    >
    > The case is that I read Julia Lerman's book about Entity Framework 4
    > (second edition). She tries to convince the reader that he/she should go
    > for it and use it.She write about improvements and enhancements. I can
    > even say that she conviced me to go for it but on the other hand I have
    > a perception that it's not as good tool as she describe it - however it
    > can work fine for small/medium projects but I am afraid it's not going
    > to prove oneself
    >
    >
    >
    >
    I have to disagree since I was using EF on a big project for the
    military with lots of users hitting the databases through EF on the
    backend through WCF.
     
    Tuesday, September 20, 2011 2:24 PM
  • On 9/20/2011 9:49 AM, niao wrote:
    > Thank for the answer,
    >
    > I cannot use other ORM than Entity Framework. The policy of the company
    > is: "Entity Framework or nothing - but is EF good enough to use it?. If
    > the performance is weak, then why should we use it instead of plain ADO.NET?
    >
    > The case is that I read Julia Lerman's book about Entity Framework 4
    > (second edition). She tries to convince the reader that he/she should go
    > for it and use it.She write about improvements and enhancements. I can
    > even say that she conviced me to go for it but on the other hand I have
    > a perception that it's not as good tool as she describe it - however it
    > can work fine for small/medium projects but I am afraid it's not going
    > to prove oneself
    >
    >
    >
    >
    I have to disagree since I was using EF on a big project for the
    military with lots of users hitting the databases through EF on the
    backend through WCF.
     
    Well, thanks for the answer. It seems to be a good news. Were you satisfied with the queries performance? Was it EF4 or other version? 
    Tuesday, September 20, 2011 2:37 PM
  • On 9/20/2011 10:37 AM, niao wrote:
    >     On 9/20/2011 9:49 AM, niao wrote:
    >      > Thank for the answer,
    >      >
    >      > I cannot use other ORM than Entity Framework. The policy of the
    >     company
    >      > is: "Entity Framework or nothing - but is EF good enough to use
    >     it?. If
    >      > the performance is weak, then why should we use it instead of
    >     plain ADO.NET?
    >      >
    >      > The case is that I read Julia Lerman's book about Entity Framework 4
    >      > (second edition). She tries to convince the reader that he/she
    >     should go
    >      > for it and use it.She write about improvements and enhancements.
    >     I can
    >      > even say that she conviced me to go for it but on the other hand
    >     I have
    >      > a perception that it's not as good tool as she describe it -
    >     however it
    >      > can work fine for small/medium projects but I am afraid it's not
    >     going
    >      > to prove oneself
    >      >
    >      >
    >      >
    >      >
    >     I have to disagree since I was using EF on a big project for the
    >     military with lots of users hitting the databases through EF on the
    >     backend through WCF.
    >
    > Well, thanks for the answer. It seems to be a good news. Were you
    > satisfied with the queries performance? Was it EF4 or other version?
     
    Query performance is based what you know how to do and what not to do
    when doing Linq queries. Some of it I have shown you. I would hope you
    are using MS-SQL No lock in your T-SQL queries. But on the other hand,
    you don't implement No Lock  in EF queries could lead to performance
    issues as an example.
     
     
    I was using EF 3.5 at the time
     
     
    <copied>
     
    Because Entity SQL query commands are cached, later executions of the
    same query take even less time.
     
    <end>
     
    A lot of times, I was using Entity SQL for querying.
     
     
    Tuesday, September 20, 2011 3:02 PM