Entity Framework Code First callback on object instantiation
问题 This may be a far fetched question, but is it possible to have a callback fire in an entity object, whenever a new instance of it has been loaded from the database (as part of e.g. a linq query), a call to Create or similar? The purpose of such a callback would be to convey a context, or set of initialization parameters, from the enclosing business object. 回答1: DbContext definitely doesn't have it but you can try to convert it back to ObjectContext and use: var objectContext = (