我正在使用EF6
與MySql
數據庫做一些非常簡單的整合。發生如何避免「不支持嵌套事務」。錯誤?
的Nested transactions are not supported.
錯誤後,我做到以下幾點:
- 嘗試添加已經存在......這就給錯誤導致一個
key
:Duplicate entry 'asdf' for key 'UserName_UNIQUE'
- 嘗試之後添加任何東西...這導致錯誤:
Nested transactions are not supported.
我想我不知道會是什麼Nested
關於這兩個查詢...什麼我做錯了:
而對於一些代碼
using (var db = C2SCore.BuildDatabaseContext())
{
db.Users.Add(new UserProfile { UserName = UserName, Password = Password });
db.SaveChanges(); // <- Errors occur here...
}
這段代碼運行(如我上述流程中的暗示),每UserProfile
我補充。
重複'key'代碼在哪裏? – rae1
@ rae1'UserName'是'key' ...如果這就是你要求的。 – Andrew
如果明確打開一個包裝TransactionScope會發生什麼?並且沒有從其他地方打開的背景,是嗎? – user2864740