Last post Mar 21, 2009 11:44 AM by dkarantonis
Mar 19, 2009 05:21 PM|canhelie|LINK
Hi everyone, I'm really struggling with trying to get the Entity framework to work well. It seems very buggy at the moment and there aren't a lot of good documentation about it. LINQ to SQL is being discontinued so that doesn't seem like a good choice.
I haven't tryied nHibernate yet but that looks like it's in beta still, too. Is there really now better solution out there? I'm really frustrated by this. Is it possible write my own entity classes for use as the model?
Mar 19, 2009 07:34 PM|dsa1971|LINK
Are you looking for something free? I don't think nHibernate is still in beta. I think nHibernate has a steeper learning curve than other ORMs though and it may be more than you need. I've heard good things about LLBLGen and I've toyed around with Lightspeed.
You can certainly can write your own entity classes but that is a lot of work.
Mar 19, 2009 07:59 PM|alberto.ferreira|LINK
This kind of questions usually creates a lot of discussion, so I will just try to share my thoughts.
I don't like to have my model objects "Mapped" to Database Entities, and let some framework manage them.
I create my own Model Objects, as they make sense in the Domain context (one Model Object could be stored in 3 different tables on DataBase). Then, I use ORM's to just access data.
I know that ORM's exist to do that (create your Model Objects mapped "transparently" to your database), NHibernate more flexible and LTS more strict, but again, I don't like to have this "magic" behind the scenes. There are a lot of discussions about that;
make a search on www.
Then, I have my Repositories and Factories that Create / Manage my Domain Objects. I'm using Linq to Sql and Entity Framework inside my Repositories so they store and retrieve data from DB. Both do what I want (because I don't use "advanced" ORM mapping,
the lack of some functionalities don't bother me).
All the validation is made inside my Domain Objects.
All this ideas are taken from Domain Driven Design, and it's impossible to share them all in this post. If you really enjoy developing (good software), you should search for DDD (if you don't know it already).
Mar 19, 2009 08:12 PM|canhelie|LINK
That sounds like a great solution. It would take a lot more time to implement but I share your distaste for automatic code generation. I'll definitely read up on DDD. In the meantime, would you happen to have any links to C#/.NET specific guides for implementing
Mar 20, 2009 05:14 AM|j.channon|LINK
I posted this same question yesterday. It seems a bit odd that Linq to SQL is disappearing with no real solution to replace it yet. In a blog post by Rob Conery he mentioned a while back that his Subsonic project would be
used for MVC but that project seems to have died so we all seem to be left in the lurch about the best way to do this.
Mar 20, 2009 05:50 AM|alberto.ferreira|LINK
I'll definitely read up on DDD.
The standard learning Curve of DDD is:
would you happen to have any links to C#/.NET specific guides for implementing DDD?
A very usual question and with a small number of answers. I don't read it, but usually this book is recommended (others don't like it):
I also have as reference (a must have):
Mar 20, 2009 07:00 PM|ricka6|LINK
>>It seems very buggy at the moment
EF is actually quite robust. Please report any bugs you find to the
>>there aren't a lot of good documentation about it.
I'm guessing you mean "There is not a lot of good documentation on using MVC with EF. That statement is correct. However EF has a rich doc set. I know the EF doc folks would love to get feedback of what is lacking, what is wrong and what they've done right.
In addition to the
EF forum, you have
MSDN on EF, numerous EF blogs. I agree we need more information on using EF with MVC.
>>LINQ to SQL is being discontinued so that doesn't seem like a good choice
That is incorrect. Linq to SQL is not being discontinued. While it's not the focus for new features, it's still supported and will have some new features and bug fixes.
Mar 21, 2009 08:11 AM|j.channon|LINK
Are you then saying we should start our projects using the EF to keep on top of things. Linq to SQL may still be supported but lets not play games, it will disappear from the recommended guidelines. Windows XP is still supported, just but MS want you to
use their latest offerings.
I also thought MVC would be using Rob Conery's Subsonic project as a recommended DAL, is this not the case anymore?
Mar 21, 2009 11:44 AM|dkarantonis|LINK
i have used the ADO entities model in order to map the application entities to the database entities. But happens when you want to use application logic entities more complex than the ones provided from your model? For example, let's say that you want a
BookCategories application entity that consist of both the Book and Category entities from your model?
A very good approach is the one that Alberto suggests and i am going to try it on the next dynamic mvc application i will implement.
Nevertheless, i have taken another approach for this issue and works quite well.
I create custom entities (used as the application logic entities) on the model level and map them to stored procedures on the database level that handle the CRUD operations. The difficult part here is to create and map the custom entity, since there is no
UI available, instead you have to manually modify the model file by opening it in its xml format (http://blogs.microsoft.co.il/blogs/gilf/archive/2009/03/13/mapping-stored-procedure-results-to-a-custom-entity-in-entity-framework.aspx).