Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework - is it suitable for Enterprise Level application?

I have a web application with:

  • 1 Terabyte DB
  • 200+ tables
  • At least 50 tables with 1+ million records each
  • 10+ developers
  • 1000s of concurrent users

This project is currently using Ad-Hoc Sql, which is generated by custom ORM solution. Instead of supporting custom ORM (which is missing a lot of advanced features), I am thinking to switch to Entity Framework.

I used EF 4.1 (Code-First) on a smaller project and it worked pretty well, but is it scalable for a much larger project above?

like image 352
Eric P Avatar asked Aug 04 '11 15:08

Eric P


People also ask

When should you not use Entity Framework?

One of the biggest reasons not to use Entity Framework Core is that your application needs the fastest possible data access. Some applications do a lot of heavy data operations with very high-performance demands, but usually business applications don't have that high of a performance demand.

When should we use Entity Framework?

The Entity Framework enables developers to work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored.

Can I use Entity Framework with .NET core?

NET Framework, as Entity Framework 6 doesn't support . NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core. The recommended way to use Entity Framework 6 in an ASP.NET Core application is to put the EF6 context and model classes in a class library project that targets .

Is Entity Framework good for large database?

YES, EF DOES PERFORM JOINS IN MEMORY IF it has a set of values that are provided as a part of query or an in memory list, basically for anything that is not from the database, EF will pull everything from the database, perform the operations in memory and returns the results.


1 Answers

I (highly) agree with marvelTracker (and Ayende's) thoughts.

Here is some further information though:

Key Strategy

There is a well-known cost when using GUIDs as Primary Keys. It was described by Jimmy Nilsson and it has been publicly available at http://www.informit.com/articles/article.aspx?p=25862. NHibernate supports the GUIDCOMB primary key strategy. However, to achieve that in EntityFramework is a little tricky and requires additional steps.

Enums

EntityFramework doesn’t support enums natively. Until June CTP which adds support for Enums http://blogs.msdn.com/b/adonet/archive/2011/06/30/walkthrough-enums-june-ctp.aspx the only way to map enumerations was using workarounds Please look at: How to work with Enums in Entity Framework?

Queries:

NHibernate offers many ways for querying data:

  • LINQ (using the re-motion’s re-linq provider, https://www.re-motion.org/web/)
  • Named Queries encapsulated in query objects
  • ICriteria/QueryOver for queries where the criteria are not known in advance
  • Using QueryOver projections and aggregates (In cases, we only need specific properties of an entity. In other cases, we may need the results of an aggregate function, such as average or count):
  • PagedQueries: In an effort to avoid overwhelming the user, and increase application responsiveness, large result sets are commonly broken into smaller pages of results.
  • MultiQueries that combine several ICriteria and QueryOver queries into a single database roundtrip
  • Detached Queries which are query objects in parts of the application without access to the NHibernate session. These objects are then executed elsewhere with a session. This is good because we can avoid complex repositories with many methods.

ISession’s QueryOver:

// Query that depends on a session:
premises = session.QueryOver<Premise>().List();

Detached QueryOver:

// Full reusable query!
var query = QueryOver.Of<Premise>();

// Then later, in some other part of ther application:
premises = query.GetExecutableQueryOver(session).List(); // Could pass IStateleSession too.

Open source

NHibernate has a lot of contribution projects available at http://sourceforge.net/projects/nhcontrib/

This project provides a number of very useful extensions to NHibernate (among other):

  • Cache Providers (for 2nd-level cache)
  • Dependency Injection for entities with no default constructor
  • Full-Text Search (Lucene.NET integration)
  • Spatial Support (NetTopologySuite integration)

Support

EntityFramework comes with Microsoft support. NHibernate has an active community:

  • https://stackoverflow.com/questions/tagged/nhibernate
  • http://forum.hibernate.org/
  • http://groups.google.com/group/fluent-nhibernate

Also, have a look at: http://www.infoq.com/news/2010/01/Comparing-NHibernate-EF-4

like image 122
Nikos Baxevanis Avatar answered Oct 19 '22 16:10

Nikos Baxevanis