Transactions with IsolationLevel Snapshot cannot be promoted

Viewed 5917

I'm trying to wrap a TransactionScope around my call to a stored procedure via Entity v.4.0.30319. I keep encountering the following exception:

Transactions with IsolationLevel Snapshot cannot be promoted.

How can I get around this?

The underlying stored procedure is basically one big insert statement into a table.

My code is as follows:

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew, GetTransactionOptions()))
{
    int? status;
    status = GetStatusIDFromEnum(newMatterCredential);

    using (MatterCredentialsEntities db = new MatterCredentialsEntities())
    {
        DateTime? objDateAnnounced = GenerateNullForDateTime(newMatterCredential.DateAnnounced);
        DateTime? objDateClosed = GenerateNullForDateTime(newMatterCredential.DateClosed);
        DateTime? objDateFinancialClosed = GenerateNullForDateTime(newMatterCredential.DateFinancialClosed);
        db.prcCreateCredential(Common.GetUserProfID(), newMatterCredential.MatterID, status, newMatterCredential.DescriptionSummary, newMatterCredential.DescriptionDetailed, newMatterCredential.BusinessEntitySectorID, newMatterCredential.BusinessEntityRoleID, newMatterCredential.UNGeographyID, newMatterCredential.ProjectName, newMatterCredential.ClientIndustryId, newMatterCredential.TransactionValue, newMatterCredential.TransactionCurrencyID, newMatterCredential.OtherParties, newMatterCredential.LegalAdvisers, newMatterCredential.DateAnnounced, newMatterCredential.DateClosed, newMatterCredential.DateFinancialClosed, newMatterCredential.Award, newMatterCredential.NotifyPartner, newMatterCredential.Notes);
    }

    scope.Complete();
}

public static TransactionOptions GetTransactionOptions()
{
    TransactionOptions tranOpt = new TransactionOptions();
    tranOpt.IsolationLevel = IsolationLevel.Snapshot;
    return tranOpt;
}
1 Answers
Related