I am using EF 6.1.0
I have below a custom DBContex object as DBEntites
public partial class DbEntities : DbContext { public DbEntities() : base("name=DbEntities") {
I have the following operations on a context object
using (var context = new DbEntities()) { var entitySet = context.Set<T>(); var res = entitySet.Where<T>(predicate).ToList(); if (context.Database.Connection.State == ConnectionState.Open) { context.Database.Connection.Close(); } return res; }
But after deleting the context object, you can still see the active connection to the database. In the state of the connection state, I see that the connection is already closed (the connection has never been true).
I use the following query to see the connection to SQL.
select db_name(dbid) , count(*) 'connections count' from master..sysprocesses where spid > 50 and spid != @@spid group by db_name(dbid) order by count(*) desc
In the description below, the number of sql connections has increased. But it never fell even after disposal. (I mean, after using a block from it, it is supposed to close the connection).
var res = entitySet.Where<T>(predicate).ToList();
Any help would be greatly appreciated.
c # sql sql-server entity-framework
Chandra mohan
source share