Riz
Riz

Reputation: 6982

Entity Framework 1 - Closing DB Connection

Do we need to close DB connection if we are using Entity Model 1 with Web Forms ?

Upvotes: 2

Views: 821

Answers (1)

magnattic
magnattic

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

Related Questions