From: Mark J. (JIRA) <tr...@fi...> - 2013-10-11 14:38:15
|
EF5: Avoid deadlocks by connection reusage and allow usage of CreateDatabaseIfNotExists DB initializer ------------------------------------------------------------------------------------------------------ Key: DNET-524 URL: http://tracker.firebirdsql.org/browse/DNET-524 Project: .NET Data provider Issue Type: Improvement Components: Entity Framework support Affects Versions: 3.2.0.0 Environment: EF 5 on .NET 4.0 and probably 4.5 Reporter: Mark Junker Assignee: Jiri Cincura # Avoid deadlocks by connection reusage: #* Assume that you have both an IDbSet<T1> and IDbSet<T2> #* Use a TransactionScope() #* Create the DbContext #* Create an instance of T1 where you initialize a property T1.X with an instance of T2 queried from the IDbSet<T2> #* Add the instance of T1 to the IDbSet<T1> #* Call SaveChanges() #* Results in a no wait lock because: #** Adding the instance of T1 partially loads the IDbSet<T1> and therefore creates a lock on the table #** SaveChanges() reopens the existing connection which produces a new FbConnectionInternal which tries to write something to a locked table #* Solution: Reuse the internal connection when the FbConnection gets reopened # Allow usage of CreateDatabaseIfNotExists DB initializer #* There's a call to context.Database.Exists() while a new TransactionScope(TransactionScopeOption.Suppress) is active #* Solution: Allow Enlist without an active transaction -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |