0

我试图让我的 MVC3 应用程序使用 MySql 数据库而不是 Sql Server 2008。我在 Mysql 中创建了关联的数据库和对象。并更新了我的 web.config 文件中的连接字符串以引用 MySql.Data.MySqlClient。

当我运行我的应用程序并尝试登录时,我收到了错误

Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.

我有一个自定义 MembershipProvider 并且在验证过程中我有以下

 using (MyContext context= new MyContext())
 {
      --some checks here
      ---
        if (verificationSucceeded)
        {
            user.passwordFailuresSinceLastSuccess = 0;
        }
        else
        {
            int failures = user.passwordFailuresSinceLastSuccess;
            if (failures != -1)
            {
                user.passwordFailuresSinceLastSuccess += 1;
                user.lastPasswordFailureDate = DateTime.UtcNow;
            }
        }
        context.SaveChanges();  ----THIS IS WHERE IT FALLS OVER
         -- some other code here 
    }

上面的代码在 Sql Server 2008 上运行得很好,但只在 MySql 上失败了。知道如何解决这个问题吗?

顺便说一句,我没有在基础表上定义任何触发器。该应用程序是带有 EF Code First 的 MVC3。谢谢,

4

1 回答 1

0

如果其他人遇到此问题,那么问题出在我的 Guid 上。要克服这个问题,请将以下内容添加到您的连接字符串

老向导=真

例如,我的连接字符串现在看起来像这样。

<add name="MyDB" connectionString="Server=localhost; Database=mydatabase; Uid=user; Pwd=mypass; Old Guids=true;" providerName="MySql.Data.MySqlClient" />
于 2012-03-08T12:06:03.097 回答