Where are the "ADO.NET Entity Framework" files in the 3-layer architecture?

If I am using ADO.NET Entity Framework in our project and we depend on a 3-tier architecture pattern we have (presentation tier - data access business tier) a project for each tier .

So when I create an entity model file, where can I put it in DAL or BL ? If I put it in the DAL and from the presentation layer I want to access the domain object in it through the business layer, we need to add a reference to the DAL in the presentation layer. Also, how do I get this type of object being created in the DAL? On the other hand, should I put the entity model file in the business layer? Which is better and why?

+2


source to share


3 answers


Ideally, the generated EntityFramework code makes up your data layer. Basically you will have some repetition in your business layer if you need the same object types in your business layer as in your data layer. Unfortunately EntityFramework doesn't really help you with your business layer.

You will now also read the information on EntityFramework which says you can / should use it as a combined data / business tier. This violates the Separation of Concerns , so I'll distract you from it, but I'm sure a ton of people do it. If you want to move from EntityFramework to NHibernate some day, you better try to isolate your ORM from the rest of your codebase and minimize any ORM communication (often by implementing something like a store pattern ).



People who speak MVC often use EntityFramework as a Model and may or may not differentiate between the data layer and the business layer (which will usually live in the Model). Even if you are using MVC, I still believe that you should decouple data access from your business rules and business logic.

0


source


You can put objects in a separate class library project, for example: Common Entity Library. This library can be referenced in any other layer of the application. Then you can work with collections in the application domain.



0


source


As I can see, the Entity Framework has your DAL. It provides the necessary tools to abstract model objects exposed by Entity Framework from database resiliency services.

The Entity Framework spans both the business layer and the DAL from this old three-layer pattern. My advice: if you are going with Entity Framework to stop thinking in terms of Presentation-> Business-> Data and think more about View-> Model.

0


source







All Articles