Explore Courses Blog Tutorials Interview Questions
0 votes
in Azure by (5.8k points)

I have tried all the other postings on the dreaded "error 19" and found that the few with answers do not apply or do not help, hence this new post. This is a very serious potential problem for all Azure+EF users.

First occurrence:

I am using the latest version of everything in a VS2013 EF6.1 Razor project (packages listed at the end). The database is hosted on SQL Azure.

After running my web app a few times (in a dev environment) I get this error: A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)

The line it dies on is always this: enter image description here

I gather the error relates to connection pooling (and running out of connections), but I cannot spot a leak anywhere.

As I access OWIN membership and other database features throughout the app I have a DatabaseContoller from which all other controllers inherit. This creates all the relevant components and disposes of them.



public class DatabaseController : Controller


    #region properties

    /// <summary>

    /// User manager - attached to application DB context

    /// </summary>

    protected UserManager<ApplicationUser> UserManager { get; set; }

    /// <summary>

    /// Role manager - attached to application DB context

    /// </summary>

    protected RoleManager<IdentityRole> RoleManager { get; set; }

    /// <summary>

    /// Application DB context

    /// </summary>

    protected ApplicationDbContext ApplicationDbContext { get; set; }

    /// <summary>

    /// Database context used by most controllers

    /// </summary>

    protected ApplicationEntities Context { get; set; }

    #endregion properties

    #region Constructors

    public DatabaseController()


        this.Context = new ApplicationEntities ();

        this.ApplicationDbContext = new ApplicationDbContext();

        this.UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(this.ApplicationDbContext));

        this.RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(this.ApplicationDbContext));

        this.UserManager.UserValidator = new UserValidator<ApplicationUser>(UserManager) { AllowOnlyAlphanumericUserNames = false };


    #endregion Constructors

    protected override void Dispose(bool disposing)


        if (disposing)


            if (UserManager != null)



                this.UserManager = null;


            if (this.RoleManager != null)



                this.RoleManager = null;


            if (this.ApplicationDbContext != null)



                this.ApplicationDbContext = null;


            if (this.Context != null)



                this.Context = null;






Packages installed

  <package id="Antlr" version="" targetFramework="net45" />

  <package id="bootstrap" version="3.1.1" targetFramework="net45" />

  <package id="EntityFramework" version="6.1.0" targetFramework="net45" />

  <package id="jQuery" version="1.11.0" targetFramework="net45" />

  <package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />

  <package id="json2" version="1.0.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.Identity.Core" version="2.0.0" targetFramework="net45" />

  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.0.0" targetFramework="net45" />

  <package id="Microsoft.AspNet.Identity.Owin" version="2.0.0" targetFramework="net45" />

  <package id="Microsoft.AspNet.Mvc" version="5.1.1" targetFramework="net45" />

  <package id="Microsoft.AspNet.Razor" version="3.1.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />

  <package id="Microsoft.AspNet.WebApi" version="5.1.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.WebApi.Client" version="5.1.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.WebApi.Core" version="5.1.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.2" targetFramework="net45" />

  <package id="Microsoft.AspNet.WebPages" version="3.1.2" targetFramework="net45" />

  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.1.2" targetFramework="net45" />

  <package id="Microsoft.Owin" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Host.SystemWeb" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.Cookies" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.Facebook" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.Google" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.OAuth" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Owin.Security.Twitter" version="2.1.0" targetFramework="net45" />

  <package id="Microsoft.Web.Infrastructure" version="" targetFramework="net45" />

  <package id="Modernizr" version="2.7.2" targetFramework="net45" />

  <package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />

  <package id="Owin" version="1.0" targetFramework="net45" />

  <package id="Owin.Security.Providers" version="1.3.1" targetFramework="net45" />

  <package id="Respond" version="1.4.2" targetFramework="net45" />

  <package id="WebGrease" version="1.6.0" targetFramework="net45" />

Assuming it is a connection leak, how can I track down the source of the leak?

1 Answer

0 votes
by (9.6k points)
edited by

Check if you are missing the following while you are referencing properties:


You can also follow these documents for more insights: click here and here

Browse Categories