Entity Framework Enterprise Architecture

So the Entity framework is great, we all know that.  But the out of the box structure can easily be improved to support n-tier application development.  To support standard enterprise architecture the Model classes (POCO classes generated from database) should not be in the same project as your data persistence code (or know anything about data persistence for that matter).  This was the big issue with the first 3 versions of EF that had everyone all fired up.  Data persistence is the code that knows about how to save to a specific data store (SQL Server, Oracle, XML, etc....).  With a few simple steps you can separate these architecture components into their own projects. 

I cannot credit for this implementation because I found the solution in the following two links, but I thought it was worthy of sharing.  We are using this structure on numerous projects at my current client and it works great.

http://www.toplinestrategies.com/dotneters/net/wcf-entity-framework-and-n-tier-solutions-part-2/?lang=en

http://allen-conway-dotnet.blogspot.com/2013/01/separating-entity-framework-poco.html

Labels: