For questions about the ADO.NET Entity Framework, the Object-Relational-Mapping (ORM) tools for the .NET Framework. Add a version specific tag as well, when applicable.
- Stackoverflow.com Wiki
Go to books ↓
This article is dedicated to discussing the latest releases of the NHibernate and Entity Framework. NHibernate is (was?) a number one ORM Framework for ages. Its feature list is growing and some things such as code-based mappings and automatic migrations have found a place in Entity Framework. Moreover, it is now open-source, so they are now accepting pull requests as well.
Some people are very quick to blame EF for bad performance and while there may be something to that in some situations, I find that very frequently a few minor adjustments in code can fix serious performance issues.
A look at how to unit test code that makes use of Repository vs using raw Entity Framework, where we will do this using mocks/test doubles.
Understanding how to set up an EF query is simple, but it can be muddled by the fact that we are dealing with what looks like C# objects. Remember, these classes represent our tables so think of them as a mechanism to interact with our database. Putting any logic on these classes can lead to unexpected issues, and potentially problems.
Updates also become especially challenging if you want the existing web site to stay ‘live’ while you change the database, i.e. the old software still works with the new database while you are updating its schema and data.
The history of data access technologies in .NET is not a pretty one. Microsoft told us to do DataSets, then SqlDataSource, then LINQ to SQL, then Entity Framework in one way, then Entity Framework in another way.
Code first migrations for Entity Framework are great but migrations add up over time. Sometimes you really need to clean them out to keep on top of what's going on. Sometimes you just wish you could start fresh.
The Entity Framework DbEntityEntry object lets you do all sorts of things you probably didn't think were possible, including getting the latest data from the database (without losing your current data) and invoking the .NET Framework validation subsystem.
Here's the best performing option when you're retrieving the objects at the end of an entity class's navigation property, either when you only want some of the objects or when you only want them some of the time.
This is a conversational talk about a deeply problematic trend I’ve seen with Entity Framework utilization across organizations small and large with teams of juniors to teams of architects. This isn’t a how to.
There’s a strong thirst for good Entity Framework resources. The issues are well-known, the frustrations are felt by many, and people want to know what to do. That’s what this entry is about.