views:

34

answers:

1

The guidance for database connections is simple and well understood. Open a connection as late as possible and close it as soon as possible. this is of course OK because of connection pooling.

what's the story for Entity Framework contexts? Does the same pattern apply?

+1  A: 

Connection pooling is up to your provider.

If you create the ObjectContext with the constructor which takes an EntityConnection, then an existing connection will be used. Else it will ask the provider for a new one.

Look at this post for details, but bear in mind that your provider can do whatever it wants.

Craig Stuntz