Home > LightSwitch > LightSwitch: Oracle An error occurred while starting a transaction on the provider connection. See the inner exception for details

LightSwitch: Oracle An error occurred while starting a transaction on the provider connection. See the inner exception for details


I got this issue today while connecting to the Oracle database. I am not taking credit of the solution but I couldn’t find a post that explains it step by step. For the benefit of the community I decided to write this post. It is also good for me to find the solution later on if I get stuck J

To fix the issue we need to create a transaction scope and call TransactionScope.complete when the execution is complete

Right click the oracle Datasource

Select View Code

Add the following code to the generated class; replace OracleDSService with the name of your class

using System.Transactions;

namespace LightSwitchApplication
{

    public partial class OracleDSService
    {
        private TransactionScope transactionScope;
        partial void SaveChanges_Executing()
        {
            transactionScope = new TransactionScope(TransactionScopeOption.Required,
                        new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted });
        }

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

In my case System.Transactions namespace wasn’t resolved. To fix that I had to add a reference to the System.Transactions assembly

To do so, follow these steps

Switch to the File View

Right click on the server project and choose Add Reference

Find the System.Transactions assembly; in my case it was at C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Transactions.dll

Save the solution, build, and run

Advertisements
Categories: LightSwitch Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: