2011-09-06 48 views
1

尝试连接并修改MySQL表中的现有数据。阅读工作正常,但当试图保存更改时,会发生以下错误。LightSwitch + MySQL错误:不支持嵌套事务

在提供程序连接上启动事务时发生错误。详情请参阅内部例外。内部异常消息: 不支持嵌套事务。

使用MySQL连接网络6.4.3

回答

我发现,在我的情况下,问题的解答。将以下代码添加到数据源代码

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 
        }); 
     } 
    } 
} 
+1

试试看看这个答案︰http://stackoverflow.com/questions/1306869/are-nested-transactions-allowed-in-mysql –

+0

This answer http:// stackoverflow .com/questions/7402946/lightswitch-does-not-allow-adding-or-modify-records-in-mysql提供了一个指向Microsoft修补程序的链接。 –

回答

0

我可以确认此修补程序的工作原理。我使用mysql connector.net版本6.4.4获得了使用MySQL的lightswitch。但是,当您建立连接并选择数据库时,您会收到此错误:“提供程序没有返回ProviderManifestToken字符串。”

要解决该问题,请单击连接属性窗口上的高级选项卡。向下滚动到安全部分并为Persist Security Info选择true。

这允许实体框架查询表。

我创建了一个测试应用程序,并发布到我的电脑,我也可以做全crud操作!

Hooray。

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