views:

50

answers:

2

What are the most important limitations of the ADO.NET Entity Framework 4.0 that business application developers should be aware of?

I have used it in some pet projects of mine and it seems very efficient, but I am concerned about the problems I will face when I am building large, more complex data-driven business applications. I am especially interested in how choosing to use the Entity Framework to access my data might limit the different design patters/architectures that I might want to use when building my project.

Because I am thinking about using the entity framework in future projects, I am only interested in limitations of the current version of the Entity Framework.

+2  A: 

You need to be aware of database chatter. Persisting an entire object graph is not really a good idea. When doing a complex query and update, EF will always try update the inserted objects. The solution to this is having complex query and update logic in a stored proc and by passing object graphs in via XML/string, etc for a single DB call.

Another issue with EF when doing design first or DB first modelling is that the Entity classes themselves are coupled to the framework via inheritance. There are several strategies around this, I have a blog post that lets to use POCO's while extracting an interface at the same time for mocking, which is really handy.

Getting the entity framework to Generate an interface for Mocking

Slappy
nice blog post - however are you aware there is a T4 template which auto-generates a mock ctx for you (same thing as your blog)
RPM1984
Nice one. You got a link?
Slappy
http://visualstudiogallery.msdn.microsoft.com/en-us/a850e686-df08-4245-b0bb-5872654285c9 It's awesome. I used it to mock out the OC/DC and then inject the fakies into my in-memory repo's using DI. Nice.
RPM1984
+2  A: 

This should probably be a CWiki, however i'll roll with the punches.

The key to a good EF implementation is an intelligent mixture of correct domain modelling (TPT for flexibility, TPH for performance, inheritance), abstraction of persistence logic (repository pattern, POCOs, dependency injection), and knowing when to use stored procedures for database-intensive tasks.

If you want to get into the nitty-gritty, the only limitations i have found with EF is lack of enum mapping support (this should be fixed soon though).

IMO, the limitation isn't really in the product, it's in the developer's lack of adherence to common architectural principals and guidelines.

RPM1984