So I have two tables: Recipe
and Step
. One recipe contains multiple Steps.
I have a WPF application and when I load a specific view, I want to asynchronously load data using Entity Framework. So I have this function
public async Task<List<recipe>> GetRecipeAsync()
{
using (var context = new RecipeSystem())
{
return await context.recipe.ToListAsync();
}
}
In the constructor of my class, I am calling the function above like this:
Recipes = _recipeService.GetRecipeAsync().Result;
But for some reason, I get an ObjectDisposedException.
If I set a breakpoint in GetRecipeAsync()
and check what value context.recipe.ToListAsync()
has, it looks fine. Step is available there.