Reputation: 6982
Do we need to close DB connection if we are using Entity Model 1 with Web Forms ?
Upvotes: 2
Views: 821
Reputation: 12998
You should use the using
-Statement to make sure your EDM model gets properly disposed after usage. EF will cover closing the connection then, if necessary.
using(MyEntities _db = new MyEntities())
{
// do stuff here
// ...
} // _db gets automagically disposed here
Upvotes: 2