2016-05-06 8 views
1

asp.net web proyectおよびSQL Server 2012標準版のEntity Framework 4で分離レベルスナップショットを使用してTransactionScopeを使用しようとしています。このエラーが発生しますTransactions with IsolationLevel Snapshot cannot be promoted.分離レベルのスナップショットエンティティフレームワーク4を使用

 using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, 
       new TransactionOptions { IsolationLevel = IsolationLevel.Snapshot })) { 

        using (var db = new Datos.TestDBDataContext(System.Configuration 
    .ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)) 
          {     
           Datos.Contacto newUser = new Datos.Contacto 
           { 
            name = user.name, 
            lastName = user.lastName, 
            type = user.type, 
            userId = user.userId, 
            email = user.Email, 
            password = Password(), 
            jobCode = user.JobCode,         
            DateCreated = user.DateCreated, 
            cityCode = user.cityCode, 
            numberPass = user.numberPass, 
            place = user.place, 
            estate = false 
           }; 

           db.Contacts.InsertOnSubmit(newUser); 
           db.SubmitChanges();     
         } 
         scope.Complete(); 
    } 

私は間違っていますか?

答えて

0

次のように試してください。IsolationLevel.Serializableを設定してください。

シリアライズ可能:揮発性データを読み取ることはできますが、変更することはできず、トランザクション中に新しい データを追加することはできません。

IsolationLevel Enumeration

var scope = new TransactionScope(TransactionScopeOption.RequiresNew, 
    new TransactionOptions { 
     IsolationLevel = IsolationLevel.Snapshot, 
     IsolationLevel = IsolationLevel.Serializable, 
}) 
+0

あなたは、この場合には何をするか、シリアライズより多くのあなたの答えを、説明できますか? – Marztres

+0

更新を参照してください。 – Sampath

+0

重複IsolationLevel、ビジュアルスタジオエラー "Duplicate initialitaon of IsolationLevel"を追加できません – Marztres

関連する問題