title: Keep Getting "A second operation started on this context before a previous operation completed" when saving to the context a second time.
body: <p>I keep getting the following error when I am executing my HttpPost form a second time.</p>
  
  <pre><code>InvalidOperationException: A second operation started on this context before a previous operation completed. 
  
  Any instance members are not guaranteed to be thread safe.
  </code></pre>
  
  <p>My ApplicationDbContext is initialised in my controller as such:</p>
  
  <pre><code>public class AssetController : Controller
  {
      private readonly ApplicationDbContext _context;
  
      public AssetController(
          ApplicationDbContext context,)
      {
          _context = context;
      }
  </code></pre>
  
  <p>And this is the function in the controller that handles the post and save:</p>
  
  <pre><code>[HttpPost]
      [ValidateAntiForgeryToken]
      public async Task&lt;IActionResult&gt; Add(IFormFile file, AddAssetViewModel model)
      {
          if (ModelState.IsValid)
          {
              var currentUser = await _userManager.GetUserAsync(HttpContext.User);
  
              var assetOwnership =
                  _context.AssetOwnership.SingleOrDefault(o =&gt; o.AssetOwnershipId == model.OwnershipId);
  
              var origin = _context.Location.SingleOrDefault(l =&gt; l.LocationId == model.OriginId);
  
              var currentLocation = _context.Location.SingleOrDefault(l =&gt; l.LocationId == model.CurrentLocationId);
  
              var division = _context.Division.SingleOrDefault(d =&gt; d.DivisionId == model.DivisionId);
  
              var normalAsset = model.NormalAsset == 2;
  
              var uploadSavePath = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads\\AssetPictures\\");
  
              var trackingNumber = GetTrackingNumber(model.OwnershipId, model.DivisionId);
  
              var asset = new Asset
              {
                  TrackingNum = trackingNumber,
                  Owner = currentUser,
                  Ownership = assetOwnership,
                  CurrentLocation = currentLocation,
                  Origin = origin,
                  ModelName = model.ModelName,
                  SerialNum = model.SerialNum,
                  Division = division,
                  Desc = model.Desc,
                  HwOpt = model.HwOpt,
                  SwOpt = model.SwOpt,
                  Availability = model.Availability,
                  Remarks = model.Remarks,
                  ReadyToSell = model.ReadyToSell,
                  PurchaseDate = model.PurchaseDate,
                  PurchasePo = model.PurchasePo,
                  NormalAsset = normalAsset,
                  MaterialNumber = model.MaterialNum,
                  IsTagged = model.IsTagged,
                  PurchasePrice = model.PurchasePrice,
                  IsDamaged = model.IsDamaged,
                  LastCalDate = model.LastCalDate,
                  Firmware = model.Firmware,
                  EstimatedNextCalDate = model.EstimatedNextCalDate,
                  LicenceExpiry = model.LicenceExpiry
              };
  
              if (file != null)
              {
                  var imageName = asset.TrackingNum + ".jpg";
  
                  if (file.Length &gt; 0)
                  {
                      using (var fileStream =
                          new FileStream(Path.Combine(uploadSavePath, imageName), FileMode.Create))
                      {
                          await file.CopyToAsync(fileStream);
                      }
                      asset.AssetPicture = imageName;
                  }
              }
  
              _context.Asset.Add(asset);
  
              await _context.SaveChangesAsync();
  
              return RedirectToAction("Index");
          }
          return View(model);
  }
  
  }
  </code></pre>
  
  <p>When I am only submitting the form for the first time, everything goes fine, item is saved into the database properly. However, when I try to add a second item, I get the error.
  Can anybody help me to fix this?
  Error output is saying it fails at</p>
  
  <pre><code>Project.Controllers.AssetController+&lt;Add&gt;d__14.MoveNext() in AssetController.cs
  +
              await _context.SaveChangesAsync();
  </code></pre>