0

I am new to EF code first approach, what I am trying to do is just inserting a record but somehow the database fails to generate in my SQL Server when my SubmitResult method is executed. I placed a breakpoint at unitOfWork.Save(); and it went through without catching any errors, I assume that if my connection string is invalid it would have thrown an exception. What could possibly be causing this?

Thanks.

[HttpPost]
public JsonResult SubmitResult(String signedRequest, String facebookName, String email, int score, String title)
{
    DateTime now = ConstantHelper.GetCurrentTime();
    try
    {
        FacebookSignedRequestUtility fbSignedRequestUtility = new FacebookSignedRequestUtility();
        fbData = fbSignedRequestUtility.Parse(FacebookUtility.AppSecret, signedRequest);

        Entry entry = new Entry();
        entry.Fbuid = fbData.FBUID;
        entry.FacebookName = facebookName;
        entry.Email = email;
        entry.Score = score;
        entry.Title = title;
        entry.CreatedDateTime = now;
        entry.ModifiedDateTime = now;

        unitOfWork.EntryRepository.Insert(entry);
        unitOfWork.Save();
    }
    catch (Exception ex)
    {
        return Json(new { status = "false" });
    }

    return Json(new { status = "true" });
}
4

1 回答 1

0

好的,发现我的 unitOfWork 类有一些问题,如果实例化我的数据库并保存它就可以工作。

  AmexContext amc = new AmexContext() ;
        amc.SaveChanges();
于 2012-09-26T07:05:10.360 回答