Archives
-
Unity Index
Updated on October 27th
-
Entity Framework Pitfalls: Null Navigation Properties
What if, after you load an entity, you have a reference property for another entity that is null yet you are sure that it points to a valid record? This will likely be because of one of two things:
-
Entity Framework Pitfalls: Deleting Detached Entities With Required References
It is common practice in O/RMs to delete an entity without actually loading id, just by knowing its id. This saves one SELECT and is great for performance. For example, using Entity Framework Code First:
-
Entity Framework Pitfalls: Non Nullable Columns in Table Per Class Hierarchy Inheritance
When you use the Table Per Class Hierarchy inheritance mapping pattern (Single Table Inheritance in Martin Fowler’s terminology), all properties of derived classes should map to nullable columns in the database. This should be pretty obvious: because all derived (concrete) entities will be stored in the same table, and each will have its own properties, that will be stored as columns in the same table. Each instance of a given entity will be stored as a record in this table, and of course each entity knows nothing about the properties of other entities.
-
Entity Framework Code First One to One With Cascade Delete
I recently had to figure how to achieve cascade deletes on a one to one mapping. The solution, I soon found out, required fluent configuration.