How to get the DbContext of an Entity RRS feed

  • Question

  • Hi,

    I use different DbContext for objects, because when I want to change and save some data from my current data entry process and don't want to save current changes! so I want get the DbContext of an entity that currently attached to, to call SaveChanges method of that DbContext.

    how can I do it?

    Amin Mashayekhi

    Tuesday, January 28, 2014 12:28 PM


  • Hello,

    If I understand correctly, you want to get the dbcontext object from an entity object.

    Unfortunately, for DbContext, it is impossible since its entities do not implement EntityObject and with DbContext, we cannot make it implement EntityObject obligatorily or it will throw an error.

    The workaround is worked however it is used for ObjectContext:



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Thursday, February 6, 2014 3:38 AM
    Wednesday, January 29, 2014 4:20 AM