Joined May 2013
·

Bernhard Millauer

Vienna
·
·
·

@pavdro: You're right! But sometimes it's better to warn people with very big signs instead telling them with a low voice that there is some danger ahead.

I never run into the problem that the connection pool was an issue. Every DbContext instance is associated with a single connection (standard settings). No matter what you do, the DbContext will reset the connection on dispose so that it can be used again by other consumers.

@seimur: you're right, this doesn't work if you use one DbContext instance for multiple threads. My example was taken from a web application where every thread gets it own DbContext instance. I will update my post accordingly.
Btw, since every pro will identify such problems I don't see it as an issue of this article. The whole purpose of this is to inform the noobs about this problem and maybe avoid it.

@avicherry: yes, it's true that sometimes you cannot avoid transactions, but the general advice is still to avoid transactions at all because it makes the whole application more complex. you mentioned multiple database context and I agree that they have to be saved at once in a transaction. but this can be done easily at a single place: spawn transaction, save dbContext1-3, complete transaction. and yes, if you really really need to know that the data you want to update exist before, you can use a transaction as well. but be warned, every succeeding read will be in a transaction as well which might not be necessary and will slow everything down or generate a deadlock.

@ganapa: The TransactionScope is used by ado.net which is the underlying provider for entity framework and is not directly bound to the connection. It can be used from outside without having any access to the connection itself.

The Transaction on the other hand is bound to the connection which makes is pretty difficult to manage in large enterprise applications.

Posted to NITROUS.IO Box with Cloud9 IDE Editor over 1 year ago

As you might seen it's about augment nitrous.io with a better code editor, not to get rid of the VM of C9.io. Cheers

Do you mean during read?

please add the content of the blog post and maybe the link to it, but please not just the link. ty

thanks! that helped me a lot!

Achievements
1,145 Karma
326,628 Total ProTip Views