More than one session per request

Using more than one object context per request is generally a bad practice. Here is why:

  1. Each object context has its own database connection. Using more than one object context means using more than one database connection per request, resulting in additional strain on the database and slower overall performance.
  2. Typically we expect the object context to keep track of our entities. When we have a multiple object contexts, each object context is not aware of the entities that tracked by the other object context and might have to query the database again for its current state or have to issue an unnecessary update.
  3. Having more than a single object context also mean that we can't take advantage on Entity Frameworks Unit of Work and have to manually manage our entities' change tracking and we might end up with multiple instances of the same entities in the same request (which using a single object context for the whole request would prevent).
  4. Having more than one object context means that the ORM have more work to do. In most cases, this is unnecessary and should be avoided.

It's usually recommended to use one object context per request. You should investigate the Session Per Request pattern.

Typically this situation results from micromanaging the object context, meaning that we create the object context just before the query and destroy it immediately after the query or operation is executed. For example, see the following code:

public T GetEntity<T>(int id)
{
    using (var ctx = new NorthwindContext())
    {
         return ctx.Get<T>(id);
    }
}

It's strongly recommended to use a contextual object context, such as the one that can be found in the link above.