LightSwitch + MySQL错误:不支持嵌套事务 [英] LightSwitch + MySQL error: Nested Transactions are not supported

查看:84
本文介绍了LightSwitch + MySQL错误:不支持嵌套事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试连接并修改MySQL表中的现有数据.读数工作正常,但是在尝试保存更改时,发生以下错误.

Trying to connect to and modify existing data in a MySQL table. The reading working fine but when trying to save a change, the following error occurs.

在提供程序连接上启动事务时发生错误.有关详细信息,请参见内部异常. 内部异常消息: 不支持嵌套交易.

An error occurred while starting a transaction on the provider connection. See the inner exception for details. Inner exception message: Nested transactions are not supported.

使用MySQL Connector Net 6.4.3

Using MySQL Connector Net 6.4.3

答案

我找到了适合我的情况的答案.将下面的代码添加到数据源代码中

I found an answer that works in my case. Add the code below to the datasource code

using System.Transactions;

namespace LightSwitchApplication
{
    public partial class <ChangeThisToYourClassName>
    {
        private TransactionScope tx;

        partial void SaveChanges_Executed()
        {
            tx.Complete();
        }

        partial void SaveChanges_Executing()
        {
            tx = new TransactionScope(TransactionScopeOption.Required, 
                  new TransactionOptions { 
                      IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                  });
        } 
    }
}

推荐答案

我可以确认此修补程序有效.我使用mysql connector.net版本6.4.4使lightswitch与MySQL一起使用.但是,当您建立连接并选择数据库时,会出现以下错误:提供程序未返回ProviderManifestToken字符串."

I can confirm that the hotfix works. I got lightswitch working with MySQL using mysql connector.net version 6.4.4. However, when you make your connection and choose your database you'll get this error: "The provider did not return a ProviderManifestToken string."

要解决此问题,请在连接属性窗口上单击高级"选项卡.向下滚动到安全性"部分,然后将持久性安全信息"选择为true.

To fix that, click on the Advanced tab on the connection properties window. Scroll down to the security section and choose true for Persist Security Info.

这允许实体框架查询表.

This allows the entity framework to query the tables.

我以此创建了一个测试应用程序,并将其发布到我的计算机上,我还可以执行完整的操作!

I created a test app with this and published to my computer and I can also do full crud operations!

万岁.

P.S.嵌套事务的修补程序在这里: http://archive.msdn.microsoft.com/KB2534087

P.S. The hotfix for the nested transactions is here: http://archive.msdn.microsoft.com/KB2534087

这篇关于LightSwitch + MySQL错误:不支持嵌套事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆