title: "The operation cannot be completed because the DbContext has been disposed"
body: <p>I am new at Entity Framework Code first and I am building a small app to get used to it.When the site runs for the first time I access existing catalog values inside the database and display this in a drop down using razor.</p>
  
  <pre><code>public void GetCats()
      {
          using (context = new RecipeContext())
          {
              try
              {
                  var query = (from r in context.Catalogues
                               select r).Distinct().ToList();
  
                  catalogues = query.Select(t =&gt; t.CatalogueName.ToString()).ToList();
                  catalogues.Sort();
  
  
              }
              catch (Exception exe)
              {
                  labMessage = exe.Message;
  
              }
  
          }
      }
  </code></pre>
  
  <p>Now when I try to add Catalogue values to the context I get the above error.</p>
  
  <pre><code>public void AddCatalogue(string catalogueName)
      {
  
          using(context = new RecipeContext())
          {
              try
              {
                  catalogueName = catalogueName.ToLower();
                  var catalogue = new RecipeCatalogue { CatalogueName = catalogueName };
  
                  if (context.Catalogues.Where(t =&gt; t.CatalogueName == catalogueName).Count() &gt; 0)
                  {
                      labMessage = "The value already exists";
                      CatalogueNameAdded = false;
                      return;
  
                  }
                  context.Catalogues.Add(catalogue);
                  context.SaveChanges();
                  catalogueNameAdded = true;
                  labMessage = "a new catalogue record was added";
  
  
              }
              catch (Exception exe)
              {
                  catalogueNameAdded = false;
                  labMessage = exe.Message;
              }
  
          }
      }
  </code></pre>
  
  <p>The values are being added to the database however but still get the above exception.</p>
  
  <p>Advice perhaps as to why I get this error. This is my Controller method which calls the above method.</p>
  
  <pre><code>[HttpPost]
      public JsonResult AddNewCatalogue(string catalogueName)
      {
          ViewModel model = new ViewModel();
          model.AddCatalogue(catalogueName);
          return Json(new { ViewModel = model });
  
      }
  </code></pre>