I've been working with PHP ORMs, and an interesting point, due to be a dynamic language is: in data-access layer I make a request to DB and it returns a "generic" object (nice name for array!) and I use this as my actual model in entire application, straight on Controller and View! That amazes a strongly typed scenario!
Now in C#, using Entity Framework as my ORM, it have its own auto-generated models (Entities), and I had made a question about this here:
Dal (with Entity Framework) and Model layers into MVC
where the conclusion was: Is wrong to use these EF's entities as my actual Model-Layer in the application, so I need to get these Data-Layer models and transpose to the truly application model in Model-Layer... to work with received data from DB in my Controllers, Views..
Also, we have more awesome questions that helped me a little bit:
- Entity Framework in Layered Architectures
- In MVC, does an ORM represent the model?
- Entity framework and Business Layer / logic
But I'm rethinking about using EF in data-layer, why? The lovely thing in Entity Framework is the DbContext and basically all ORM works around it, and if I transpose these EF's entities to my model-layer models I'll be wasting all that goodies that make things easier and faster, besides of the hard work to transpose classes that really annoys me and make things harder ! (please don't say AutoMapper, I can't use this in my job, and I'm not searching for a third party solution).
Why using Entity Framework in Model-layer or in a single layer is faster:
I would have all the auto-generated models in the model layer, and I could use them in my entire application, also I'll take full advantage of all Entity Framework with DbContext, quick and easy.
However, that scares me because I would access data straight in a non-data layer and Controller and View can access all data-related stuff, and we all know about the problems about this approach.
So my question is:
I have assumed that ORM is to make data-access development easier and faster, simple as I can do with PHP an it works pretty well. Also, I assume that's perfect for agile development, because working with Stored Procedures for small and quick works is a pain (although I like SP). So here is Entity Framework and DbContext to make things easier and faster, right? But, agile development is not about to slap together at all, so that's why in all questions we're talking about placing EF in data-layer instead Model-Layer.
But this make development with EF slower and painful and we waste its advantages, and seriously, working with Stored Proceures in this case is faster. We don't have a really rapid development using EF in layered architectures?