If your solution is completely green, I like to use the first code approach in the entity structure (goodbye to the shameless plugin, but I posted a tutorial on my blog about this http://www.terric.co.uk/code-first-entity-framework-and -sql-migrations / ). I like the control it gives me, which I cannot get when I create .edmx.
Moving to the structure, I usually separate the layers of my project into separate assemblies: Domain (and Data) and WebUI, structured with the following folders (namespaces):
Domain (business layer and data layer assembly) Data (contains my EF data context and Interface to the context) Entities (contains my POCO objects for the context) WebUI (presentation layer assembly) Infrastructure (contains my dependency inject initialiser)
I never make my entities and instead use concrete in my presentation layer, however in the context I will always use DI, as I may need / use ADO.Net (especially for legacy applications), where my domain will still use ADO .Net to read / write my POCO objects. That way, when I end up getting the opportunity to implement ORM with my legacy application, I can just DI the ORM version of my domain.
As a note to this, if you followed the repository pattern, you can always link them and DI your repositories. In any case, your POCOs must be specific to the solution, so the underlying data structure will not change dramatically, so I never do them.
source share