How to Convert DBContext Object to ObjectContext in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

Below is a function that converts the DBContext object to ObjectContext in C#.

How to Convert DBContext Object to ObjectContext in C# ?

public static ObjectContext ConvertContext(DbContext db)
{
   return ((IObjectContextAdapter)db).ObjectContext;
}
%d bloggers like this: