Search code examples
c#entity-frameworkwcf-data-services

does EntityFrameworkDataService close the db connection after querying?


I have an EntityFrameworkDataService implemented on a server application where client applications can query from it. I googled around for a while but couldn't find out how to close the database connection once we're done with a query. Is there a way to do this or is it done automatically?


Solution

  • See here:

    The Entity Framework opens connections only when required, for example to execute a query or to call SaveChanges, and then closes the connection when the operation is complete.

    I've no reason at all to assume that EntityFrameworkDataService<T> will force its DbContext to keep connections open. Of course you can always check by profiling the database.