Entity Framework
Entity Framework
Thanks to Keith (comment #1 at http://weblogs.asp.net/johnkatsiotis/archive/2010/04/28/huge-ef4-inheritance-bug.aspx#7464062) for that title, btw. After coming from NHibernate, EF4 is an enormous pain to work with. Unlike NHibernate, which basically lets you map any relationship you can dream of, EF4 has a lot of issues with inheritance. Here’s a pretty big one IMO: Take a look at this object hierarchy: Before I continue, if you think we’re working on an edge case I have to disagree. One of the tenets of OOP is the idea of encapsulation – there’s no reason a base class shouldn’t be able...
When you retrieve an entity from the database, Entity Framework handles lazy loading for you by creating a proxy for your model class. There is, however, a little caveat. Take the following code: 1: using (MSEntities ent = new MSEntities("name=MSEntities"))
2: {
3: // I already added Microsoft to the database, with ID 1
4: Employee billGates = new Employee()
...
I’m working on a new project using .NET4, MVC2 and EntityFramework. For the last couple years I’ve been using NHibernate as my ORM of choice but there are a lot of similarities between NHibernate and EntityFramework actually so the learning curve is quite small. There are a number of things that make me long for NHibernate, but one stands out in my mind: lazy loading. One of my first issues with EF was trying to track down a bug: ClassA has a property reference to ClassB, but the property is always null even when ClassB exists in the database. After...