Which is the Best Practise in Declaring Entity FrameWork Contexts
function() { DBContext context = new DBContext(); //Entity code return ; }
You can avoid the lazy-loading EF behaviour by calling .ToList() on the IEnumerable before the context is disposed (i.e. within your using block)
.ToList()
IEnumerable
using