I'm trying to subscribe my context to the OnjectMaterialized event following this, like so:
((IObjectContextAdapter)this).ObjectContext
.ObjectMaterialized += ObjectContext_OnObjectMaterialized;
But I'm using EF6 and the OnContextCreated method mentioned on that post does not exists in this version.
I tried subscribing the materialized event at the context constructor, but then, if the database is deleted (which we do often during integration tests), the event is no longer subscribed. We tried subscribing again after Database.Delete() but it doesn't work either.
So my question is, where should I properly subscribe the ObjectMaterialized event using Entity Framework 6?