namespace Before; /// /// Base class for every DB-backed domain object. Fakes the active-record part /// of EF: each entity carries its own and, once it has been /// created/saved through a context, a back-reference to that context. /// /// is the dependency this base class leaks. The /// "after" situation (Yak 02) removes this inheritance entirely — domain /// objects become plain POCOs that know nothing about a DbContext. /// public class DbBase { /// /// Primary key. Fresh (unsaved) entities have ; /// assigns a real id, faking EF's identity /// generation. /// public Guid Id { get; set; } /// /// Active-record back-reference: "I know which context created me". This /// is the leak the exercise exposes — from a plain domain object you can /// reach straight into the persistence layer. internal set because /// only the owning may (re)assign it; consumers /// (including the WebApp, and the tests) can only read it. /// public DbContext? DbContext { get; internal set; } }