简体   繁体   中英

Entity cannot resolve symbol SaveChanges

I just added an entity object to my project. When I go to savechanges, it is telling me that it is not found.

Here is an example:

在此处输入图片说明

And the code:

[Authorize]
[SessionExpireFilter]
public ActionResult Delink()
{
  var control = Logging.StartLog();
  control.ClassName = System.Reflection.MethodBase.GetCurrentMethod().Name;

  try
  {
    if (CurrentCustomerSession.Current.AccountGuid == Guid.Empty)
    {
      Logging.WriteLog(control, "Redirecting to AddCustomer:Customer since CurrentAccountGuid == null");
      return RedirectToAction("AddCustomer", "Customer");
    }

    var username = System.Web.HttpContext.Current.User.Identity.Name.ToLower();
    var entities = new SuburbanPortalEntities();
    var qry = (from x in entities.UsersAccountLinks
               where x.AccountId == CurrentCustomerSession.Current.AccountGuid && x.aspnet_Users.LoweredUserName == username
      select x).FirstOrDefault();
    if(qry == null)
      return View("Error");

    qry.AccountId = Guid.Empty;
    entities.SaveChanges();
    CurrentCustomerSession.Current.AccountGuid = Guid.Empty;
    CurrentCustomerSession.Current.AccountNumber = string.Empty;
    CurrentCustomerSession.Current.Branch = string.Empty;
    //return View("");
    return RedirectToAction("AccountScreen", "Customer");
  }
  catch (Exception ex)
  {
    Logging.WriteLog(control, string.Format("exception: {0}", ex.Message));
    Logging.WriteException(control, ex);
    return View("Error");
  }
  finally
  {
    Logging.WriteLog(control, "End Delink");
    Logging.FlushLog(control);
  }
}

I'm not sure what to check at this point. I have deleted SuburbanPortalEntities and readded it without any success.

Any suggestions where I look?

For future reference, I had 6.1.x installed of Entity Framework. When I checked the nuget packages, it showed 6.2.0 available. Once I updated to that version of Entity Framework, it started working correctly.

我通过将 Entity Framework 版本从 6.2.0 降级到 6.1.0 再降回 6.2.0 解决了这个问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM