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.

                             

No Comments