In my projects I often don't have a separate Data Access Layer, but I like to add some raw SQL methods to my Entities for performance reasons.
So I have a MassUpdateSomethingAndPersist() in one of my Entity classes. To do the mass update I need to call dbContext.Database.ExecuteSqlCommand
from within the Entity. But of course I need a reference to the DbContext first.
Question
Is it possible to get the DbContext from within the Entity? Using reflection for this is not an issue for me, because these are relatively heavy operations anyway.